//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.folder.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.hustcad.plm.basic.designmodule.factory.impl.TyplmInterfaceFactory;
import com.hustcad.plm.basic.util.TyplmEntityBaseUtil;
import com.hustcad.plm.basic.util.TyplmLoggerUtil;
import com.hustcad.plm.pdm.common.service.entity.TyplmEntityBaseService;
import com.hustcad.plm.pdm.common.util.CommonUtil;
import com.hustcad.plm.pdm.common.util.TyplmPermissionsUtil;
import com.hustcad.plm.pdm.container.service.ITyplmContainerHelper;
import com.hustcad.plm.pdm.container.service.TyplmContainerService;
import com.hustcad.plm.pdm.folder.mapper.TyplmCabinetMapper;
import com.hustcad.plm.pdm.folder.mapper.TyplmSubfolderLinkMapper;
import com.hustcad.plm.pdm.folder.model.constant.FolderErrorCodeEnum;
import com.hustcad.plm.pdm.folder.model.dto.FolderEntityQuery;
import com.hustcad.plm.pdm.folder.model.dto.MoveFolderDTO;
import com.hustcad.plm.pdm.folder.model.dto.QuerySubFolderOutDTO;
import com.hustcad.plm.pdm.folder.model.dto.RpmActiveFolderDTO;
import com.hustcad.plm.pdm.folder.model.dto.RpmActiveFolderExtDTO;
import com.hustcad.plm.pdm.folder.model.dto.SubFolderOrCabinetDTO;
import com.hustcad.plm.pdm.folder.model.dto.SubfolderDTO;
import com.hustcad.plm.pdm.folder.model.vo.CadFolderVO;
import com.hustcad.plm.pdm.folder.model.vo.FolderOrCabinetPathVo;
import com.hustcad.plm.pdm.folder.model.vo.SubFolderPathVO;
import com.hustcad.plm.pdm.folder.model.vo.SubfolderDetailVO;
import com.hustcad.plm.pdm.folder.model.vo.SubfolderVO;
import com.hustcad.plm.pdm.folder.model.vo.SubfolderWebVO;
import com.hustcad.plm.pdm.folder.service.TyplmCabinetService;
import com.hustcad.plm.pdm.folder.service.TyplmSubFolderLinkService;
import com.hustcad.plm.pdm.folder.service.TyplmSubFolderService;
import com.hustcad.plm.pdm.type.service.TyplmTypeExtService;
import com.hustcad.plm.pdm.user.model.dto.PermissionDomainDTO;
import com.hustcad.plm.pdm.user.model.vo.ContainerVO;
import com.hustcad.plm.pdm.user.service.TyplmAuthorityDomainService;
import com.hustcad.plm.pdm.user.service.TyplmDomainService;
import com.hustcad.plm.pdm.user.service.TyplmUserService;
import com.ty.basic.common.ITyCabined;
import com.ty.basic.common.ITyContained;
import com.ty.basic.common.ITyDomainAdministratored;
import com.ty.basic.common.ITyFolderedQuery;
import com.ty.basic.constant.ContainerConstant;
import com.ty.basic.dto.TableParamDTO;
import com.ty.basic.entity.CTyEntityBaseDO;
import com.ty.basic.entity.CTyIterateBaseDO;
import com.ty.basic.entity.IdentifierEntity;
import com.ty.basic.entity.TyBaseObject;
import com.ty.basic.entity.domain.DomainDO;
import com.ty.basic.entity.folder.CabinetDO;
import com.ty.basic.entity.folder.SubfolderDO;
import com.ty.basic.entity.folder.SubfolderLinkDO;
import com.ty.basic.entity.org.UserDO;
import com.ty.basic.handler.exceptionhandler.exception.ResponseCodeEnum;
import com.ty.basic.handler.exceptionhandler.exception.TyException;
import com.ty.basic.service.snow.SnowflakeIdComponent;
import com.ty.basic.session.TyAccountContext;
import com.ty.basic.util.EntityBaseUtil;
import com.ty.basic.util.StringUtil;
import com.ty.basic.util.TyEntityMapperUtil;
import com.ty.basic.utils.BatchQueryHelper;
import com.ty.basic.utils.ConvertUtils;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

@Service
public class TyplmSubFolderLinkServiceImpl implements TyplmSubFolderLinkService {
    private static final Logger log = LoggerFactory.getLogger(TyplmSubFolderLinkServiceImpl.class);
    protected static final List<String> CONTAINER_TYPE;
    private static final SubfolderDO SUBFOLDERDONULL = null;
    private static final SubfolderDetailVO SUBFOLDERDETAILVONULL = null;
    private static final String BOTYPE = "botype";
    private static final String CONTAINERNAME_MESSAGE = "containerName:";
    private static final String CONTAINERTYPE_MESSAGE = ",containerType:";
    @Resource
    private TyplmSubfolderLinkMapper typlmSubfolderLinkMapper;
    @Resource
    private TyplmCabinetMapper typlmCabinetMapper;
    @Resource
    private TyplmAuthorityDomainService typlmAuthorityDomainService;
    @Resource
    private SnowflakeIdComponent snowflakeIdComponent;
    @Resource
    private TyplmPermissionsUtil typlmPermissionsUtil;
    @Autowired
    private TyplmSubFolderService typlmSubFolderService;
    @Resource
    private TyplmDomainService typlmDomainService;
    @Autowired
    private TyplmContainerService typlmContainerService;
    @Autowired
    private TyplmCabinetService typlmCabinetService;
    @Resource
    private TyplmInterfaceFactory typlmInterfaceFactory;
    @Value("${subfolder.entity.show-all-view-version:true}")
    private Boolean showAllViewVersion;
    @Resource
    private TyplmTypeExtService typlmTypeExtService;
    @Resource
    private SqlSessionFactory sqlSessionFactory;
    @Resource
    private TyplmEntityBaseService typlmEntityBaseService;

    public TyplmSubFolderLinkServiceImpl() {
    }

    public int deleteSubFolderLinkByBoid(BigInteger boid, String botype) {
        Example ex = new Example(SubfolderLinkDO.class, true, true);
        Example.Criteria criteria = ex.createCriteria();
        criteria.andEqualTo("boid", boid);
        criteria.andEqualTo("botype", botype);
        return this.typlmSubfolderLinkMapper.deleteByExample(ex);
    }

    public List<SubfolderWebVO> querySubfolderByParent(BigInteger oid, String otype) {
        return this.typlmSubfolderLinkMapper.querySubfolderByParentOidAndOtype(oid, otype);
    }

    public List<SubfolderWebVO> queryAllSubfolderByParent(SubfolderDTO subfolderDTO) {
        List<SubfolderWebVO> subfolderWebVOS = this.getAllSubFolderByParent(subfolderDTO);
        TyplmLoggerUtil.debug(log, () -> {
            return "queryAllSubfolderByParent,根据父对象查询所有子文件夹集合返回,subfolderWebVOS==>【{}】";
        }, () -> {
            return new Object[]{subfolderWebVOS};
        });
        return this.buildFolderTree(subfolderDTO.getOid().toString(), subfolderWebVOS);
    }

    public List<SubfolderWebVO> querySubfolderAndCountByParent(BigInteger oid, String otype) {
        FolderEntityQuery folderEntityQuery = new FolderEntityQuery();
        folderEntityQuery.setFolderID(oid);
        folderEntityQuery.setFolderOtype(otype);
        folderEntityQuery.setShowAllViewVersion(this.showAllViewVersion);
        this.initQueryCondition(folderEntityQuery);
        List<SubfolderWebVO> subfolderWebVOS = this.typlmSubfolderLinkMapper.querySubfolderAndCountByParent(folderEntityQuery);
        TyplmLoggerUtil.debug(log, () -> {
            return "querySubfolderAndCountByParent,获取子文件夹并统计文件夹下对象数量返回,subfolderWebVOS==>【{}】";
        }, () -> {
            return new Object[]{subfolderWebVOS};
        });
        if (!CollectionUtils.isEmpty(subfolderWebVOS)) {
            subfolderWebVOS.forEach((item) -> {
                if ("true".equals(item.getHasChildren())) {
                    item.setIsLeaf(false);
                }

            });
        }

        return subfolderWebVOS;
    }

    private void initQueryCondition(FolderEntityQuery folderEntityQuery) {
        if (!Objects.isNull(folderEntityQuery.getFolderID()) && !BigInteger.ZERO.equals(folderEntityQuery.getFolderID()) && !StringUtils.isBlank(folderEntityQuery.getFolderOtype())) {
            List<TableParamDTO> tableParamDTOS = new ArrayList();
            List<Class<? extends CTyEntityBaseDO>> folderedQueryClassList = TyEntityMapperUtil.getAssignableClazzByInterface(ITyFolderedQuery.class);
            if (!CollectionUtils.isEmpty(folderedQueryClassList)) {
                Iterator var4 = folderedQueryClassList.iterator();

                while(var4.hasNext()) {
                    Class<? extends CTyEntityBaseDO> item = (Class)var4.next();
                    if (TyEntityMapperUtil.checkEntityTableExistInSystem(item)) {
                        Optional<TableParamDTO> tableParam = TyplmEntityBaseUtil.getTableParam(item);
                        tableParam.ifPresent(tableParamDTOS::add);
                    }
                }

                folderEntityQuery.setTableParamDTOS(tableParamDTOS);
                if (folderEntityQuery.getTableParamDTOS().stream().anyMatch(TableParamDTO::isIterated)) {
                    folderEntityQuery.setHaveIterEntity("Y");
                }

            }
        }
    }

    public List<CadFolderVO> getChildFolderByParent(String oid, String otype) {
        this.validSubfolderId(oid);
        List<CadFolderVO> subfolderVOList = new ArrayList();
        List<SubfolderWebVO> subfolderDOList = new ArrayList();
        TyplmLoggerUtil.debug(log, () -> {
            return "getChildFolderByParent入参,otype==>【{}】";
        }, () -> {
            return new Object[]{otype};
        });
        if (!CONTAINER_TYPE.contains(otype)) {
            return subfolderVOList;
        } else {
            BigInteger oidInt = new BigInteger(oid);
            if ("ty.inteplm.product.CTyPDMLinkProduct".equals(otype)) {
                subfolderDOList = this.getSubfolderByProductId(oidInt);
            }

            if ("ty.inteplm.library.CTyLibrary".equals(otype)) {
                subfolderDOList = this.getSubfolderByLibraryId(oidInt);
            }

            if ("ty.inteplm.project.CTyProject".equals(otype)) {
                subfolderDOList = this.getSubFolderByProject(oidInt);
            }

            if ("ty.inteplm.folder.CTySubFolder".equals(otype)) {
                subfolderDOList = this.typlmSubfolderLinkMapper.querySubfolderByParentOidAndOtype(oidInt, otype);
            }

            return (List)(!CollectionUtils.isEmpty((Collection)subfolderDOList) ? SubfolderWebVO.convertDOToVO((List)subfolderDOList) : subfolderVOList);
        }
    }

    public List<SubfolderWebVO> getSubfolderByLibraryId(BigInteger oid) {
        return this.getSubFolderByContainer(oid, "ty.inteplm.library.CTyLibrary");
    }

    public List<SubfolderWebVO> getSubfolderByProductId(BigInteger oid) {
        return this.getSubFolderByContainer(oid, "ty.inteplm.product.CTyPDMLinkProduct");
    }

    public List<SubfolderWebVO> getSubFolderByProject(BigInteger oid) {
        return this.getSubFolderByContainer(oid, "ty.inteplm.project.CTyProject");
    }

    private List<SubfolderWebVO> getSubFolderByContainer(BigInteger oid, String oType) {
        ContainerVO containerVO;
        try {
            containerVO = this.typlmContainerService.getContainerVOByID(oType, oid.toString());
            TyplmLoggerUtil.debug(log, () -> {
                return "getSubFolderByContainer,根据容器ID和容器类型获取容器名称返回,containerVO==>【{}】";
            }, () -> {
                return new Object[]{containerVO};
            });
        } catch (TyException var5) {
            return new ArrayList();
        }

        return (List)(Objects.isNull(containerVO) ? new ArrayList() : this.getSubfolderByDefaultcabinet(new BigInteger(containerVO.getDefaultcabinetoid()), containerVO.getDefaultcabinetotype()));
    }

    public List<SubfolderWebVO> getSubfolderByDefaultcabinet(BigInteger defaultcabinetoid, String defaultcabinetotype) {
        return this.typlmSubfolderLinkMapper.querySubfolderByParentOidAndOtype(defaultcabinetoid, defaultcabinetotype);
    }

    public SubfolderDO querySubFolderByFullPath(String containerType, String containerName, String fullPath) {
        List<String> folderPath = StringUtil.cleanEmptyString(fullPath.split("/"));
        if (CollectionUtils.isEmpty(folderPath)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"fullPath"})));
        } else if (ContainerConstant.getNormalContainerType().stream().anyMatch((item) -> {
            return item.equalsIgnoreCase(containerType);
        })) {
            ContainerVO containerVO = this.typlmContainerService.getContainerVOByName(containerType, containerName);
            TyplmLoggerUtil.debug(log, () -> {
                return "querySubFolderByFullPath,根据容器名称和容器类型获取容器名称返回,containerVO==>【{}】";
            }, () -> {
                return new Object[]{containerVO};
            });
            BigInteger cabinetOID = new BigInteger(containerVO.getDefaultcabinetoid());
            String cabinetOtype = containerVO.getDefaultcabinetotype();
            if (cabinetOID.compareTo(BigInteger.ZERO) != 0 && !StringUtils.isBlank(cabinetOtype)) {
                SubfolderDO subfolderDO = this.querySonFolderByParentAndSonName(cabinetOID, cabinetOtype, (String)folderPath.get(0));
                TyplmLoggerUtil.debug(log, () -> {
                    return "querySubFolderByFullPath,获取文件柜下的文件夹返回,subfolderDO==>【{}】";
                }, () -> {
                    return new Object[]{subfolderDO};
                });
                if (Objects.isNull(subfolderDO)) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{fullPath})));
                } else {
                    return this.getSubfolderDO(folderPath, subfolderDO);
                }
            } else {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{containerName})));
            }
        } else {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{containerType})));
        }
    }

    public SubfolderDO queryParentFolderByFullPath(ContainerVO containerVO, List<String> folders) {
        TyplmLoggerUtil.debug(log, () -> {
            return "queryParentFolderByFullPath的参数,folders==>【{}】";
        }, () -> {
            return new Object[]{folders};
        });
        if (CollectionUtils.isEmpty(folders)) {
            return SUBFOLDERDONULL;
        } else {
            BigInteger cabinetOid = new BigInteger(containerVO.getDefaultcabinetoid());
            SubfolderDO subfolderDO = this.querySonFolderByParentAndSonName(cabinetOid, containerVO.getDefaultcabinetotype(), (String)folders.get(0));
            if (Objects.isNull(subfolderDO)) {
                return SUBFOLDERDONULL;
            } else {
                folders.remove(0);
                Iterator<String> iterator = folders.iterator();

                while(iterator.hasNext()) {
                    String next = (String)iterator.next();
                    String folderName = "";

                    try {
                        folderName = URLDecoder.decode(next, StandardCharsets.UTF_8.name());
                    } catch (UnsupportedEncodingException var9) {
                        TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_FOLDER_NAME_DECODER_ERROR, new String[0]);
                    }

                    SubfolderDO curSubfolder = this.querySonFolderByParentAndSonName(subfolderDO.getOid(), subfolderDO.getOtype(), folderName);
                    if (Objects.isNull(curSubfolder)) {
                        break;
                    }

                    subfolderDO = curSubfolder;
                    iterator.remove();
                }

                return subfolderDO;
            }
        }
    }

    private SubfolderDO getSubfolderDO(List<String> folderPath, SubfolderDO subfolderDO) {
        SubfolderDO childSubfolder = subfolderDO;

        for(int i = 1; i < folderPath.size(); ++i) {
            String folderName = "";

            try {
                folderName = URLDecoder.decode((String)folderPath.get(i), StandardCharsets.UTF_8.name());
            } catch (UnsupportedEncodingException var7) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_FOLDER_NAME_DECODER_ERROR, new String[]{"folderName:" + (String)folderPath.get(i)});
            }

            childSubfolder = this.querySonFolderByParentAndSonName(childSubfolder.getOid(), childSubfolder.getOtype(), folderName);
            if (Objects.isNull(childSubfolder)) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{folderName})));
            }
        }

        return childSubfolder;
    }

    public SubfolderDO createSubfolder(SubfolderVO subfolderVO, List<String> subfolderNames, UserDO userDO) {
        SubfolderDO subfolderDO = null;

        for(Iterator var5 = subfolderNames.iterator(); var5.hasNext(); subfolderDO = this.createSubfolder(subfolderVO, userDO)) {
            String subfolderName = (String)var5.next();
            subfolderVO.setName(subfolderName);
            if (!Objects.isNull(subfolderDO)) {
                subfolderVO.setParentOid(subfolderDO.getOid().toString());
                subfolderVO.setParentOtype(subfolderDO.getOtype());
            }
        }

        return subfolderDO;
    }

    public SubfolderDO updateSubfolder(SubfolderWebVO subfolderWebVO, UserDO userDO) {
        long startTime = System.currentTimeMillis();
        SubfolderDO subfolder = this.validSubfolderWebVO(subfolderWebVO);
        TyplmLoggerUtil.debug(log, () -> {
            return "updateSubfolder入参校验，返回,subfolder==>【{}】";
        }, () -> {
            return new Object[]{subfolder};
        });
        String permissionName = "修改_读取";
        SubfolderDO updateSubfolder = new SubfolderDO();
        updateSubfolder.setOid(subfolder.getOid());
        int count = 0;
        String folderName = subfolderWebVO.getName();
        if (StringUtils.isNotBlank(folderName)) {
            if (!folderName.equals(subfolder.getName())) {
                permissionName = permissionName + "_修改标识";
            }

            updateSubfolder.setName(folderName);
            ++count;
        }

        if (subfolderWebVO.getDescription() != null) {
            ++count;
            updateSubfolder.setDescription(subfolderWebVO.getDescription());
        }

        if (count == 0) {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹无需更新。";
            });
            return updateSubfolder;
        } else {
            this.modifyDomain(subfolderWebVO, subfolder, updateSubfolder);
            List<String> permissionList = new ArrayList();
            permissionList.add(permissionName);
            List<TyBaseObject> listObj = new ArrayList();
            listObj.add(subfolder);
            List<BigInteger> idList = new ArrayList();
            Map<String, List<CTyIterateBaseDO>> typeToIdMap = null;
            TyplmLoggerUtil.debug(log, () -> {
                return "updateSubfolder <== subfolder= 【{}】, subfolder= 【{}】";
            }, () -> {
                return new Object[]{updateSubfolder, subfolder};
            });
            if (!updateSubfolder.getDomainoid().equals(subfolder.getDomainoid())) {
                TyplmLoggerUtil.debug(log, () -> {
                    return "需要修改文件夹的域";
                });
                List<SubfolderDO> subfolderDOS = this.typlmSubFolderService.getInheritedDomainSubFolderListByParent(updateSubfolder.getOid());
                if (CollUtil.isNotEmpty(subfolderDOS)) {
                    idList = (List)subfolderDOS.stream().map((subfold) -> {
                        return subfold.getOid();
                    }).collect(Collectors.toList());
                }

                TyplmLoggerUtil.debug(log, () -> {
                    return "查到子文件夹完成";
                });
                this.getSubfolderPermission(subfolderDOS, subfolder, listObj, permissionList, permissionName);
                TyplmLoggerUtil.debug(log, () -> {
                    return "得到子文件夹的权限校验所需要的参数完成";
                });
                this.getSubfolderUpdateDomainPermission(updateSubfolder, subfolder, permissionList, listObj);
                TyplmLoggerUtil.debug(log, () -> {
                    return "得到目标域的【通过移动创建】权限完成";
                });
                List<BigInteger> ids = new ArrayList();
                ids.add(new BigInteger(subfolderWebVO.getOid()));
                ids.addAll((Collection)idList);
                typeToIdMap = this.getLatestObjMap(ids, permissionList, listObj);
                TyplmLoggerUtil.debug(log, () -> {
                    return "得到文件夹下关联对象的权限完成";
                });
            }

            TyplmLoggerUtil.debug(log, () -> {
                return "updateSucheckObjectPermissionList入参= 【{}】";
            }, () -> {
                return new Object[]{listObj};
            });
            TyplmLoggerUtil.debug(log, () -> {
                return "updateSubfolder 组装权限参数花了【{}】";
            }, () -> {
                return new Object[]{System.currentTimeMillis() - startTime};
            });
            this.typlmPermissionsUtil.checkObjectPermissionList(userDO, listObj, permissionList, true);
            long startTimegs = System.currentTimeMillis();
            updateSubfolder.setUpdatoroid(userDO.getOid());
            updateSubfolder.setUpdatorotype(userDO.getOtype());
            TyplmEntityBaseUtil.fillCommonFieldForUpdate(updateSubfolder);
            TyplmLoggerUtil.debug(log, () -> {
                return "修改当前文件夹";
            });
            this.typlmSubFolderService.updateSubfolderDO(updateSubfolder);
            if (!updateSubfolder.getDomainoid().equals(subfolder.getDomainoid())) {
                if (idList != null && !((List)idList).isEmpty()) {
                    List<SubfolderDO> subfolderDOList = (List)((List)idList).stream().map((id) -> {
                        SubfolderDO subfold = new SubfolderDO();
                        subfold.setOid((BigInteger) id);
                        subfold.setDomainoid(updateSubfolder.getDomainoid());
                        return subfold;
                    }).collect(Collectors.toList());
                    long startTimeSubfold = System.currentTimeMillis();
                    this.typlmEntityBaseService.batchUpdateSelectiveWithCommit(subfolderDOList, true);
                    TyplmLoggerUtil.debug(log, () -> {
                        return "updateSubfolder 更新子文件夹花了【{}】";
                    }, () -> {
                        return new Object[]{System.currentTimeMillis() - startTimeSubfold};
                    });
                }

                long startTimeDomain = System.currentTimeMillis();
                this.updateObjDomain(typeToIdMap, updateSubfolder);
                TyplmLoggerUtil.debug(log, () -> {
                    return "updateSubfolder 更新关联对象的域花了【{}】";
                }, () -> {
                    return new Object[]{System.currentTimeMillis() - startTimeDomain};
                });
            }

            TyplmLoggerUtil.debug(log, () -> {
                return "updateSubfolder 更新花了【{}】";
            }, () -> {
                return new Object[]{System.currentTimeMillis() - startTimegs};
            });
            return updateSubfolder;
        }
    }

    private void updateObjDomain(Map<String, List<CTyIterateBaseDO>> typeToIdMap, SubfolderDO updateSubfolder) {
        TyplmLoggerUtil.debug(log, () -> {
            return "updateObjDomain的参数，typeToIdMap= 【{}】";
        }, () -> {
            return new Object[]{typeToIdMap};
        });
        if (!MapUtil.isEmpty(typeToIdMap)) {
            int updateCount = 1000;
            SqlSession sqlSession = this.sqlSessionFactory.openSession(ExecutorType.BATCH);
            Throwable var5 = null;

            try {
                Iterator var6 = typeToIdMap.keySet().iterator();

                while(var6.hasNext()) {
                    String typeName = (String)var6.next();
                    if (StringUtils.isNotBlank(typeName) && CollUtil.isNotEmpty((Collection)typeToIdMap.get(typeName))) {
                        String tableName = CommonUtil.getTableName(typeName);
                        if (Objects.isNull(tableName)) {
                            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"tableName|" + typeName})));
                        }

                        List<BigInteger> branchIdList = new ArrayList();
                        List<BigInteger> oidList = new ArrayList();
                        Iterator var11 = ((List)typeToIdMap.get(typeName)).iterator();

                        while(var11.hasNext()) {
                            CTyIterateBaseDO iterateBaseDO = (CTyIterateBaseDO)var11.next();
                            if (iterateBaseDO.getBranchid() != null) {
                                branchIdList.add(iterateBaseDO.getBranchid());
                            }

                            if (iterateBaseDO.getOid() != null) {
                                oidList.add(iterateBaseDO.getOid());
                            }
                        }

                        boolean lockFlag = false;
                        if (CollUtil.isNotEmpty((Collection)typeToIdMap.get(typeName)) && ((List)typeToIdMap.get(typeName)).get(0) != null && StringUtils.isNotBlank(((CTyIterateBaseDO)((List)typeToIdMap.get(typeName)).get(0)).getLockstateinfo())) {
                            lockFlag = true;
                        }

                        TyplmLoggerUtil.debug(log, () -> {
                            return "updateObjDomain，typeName= 【{}】，branchIdList= 【{}】";
                        }, () -> {
                            return new Object[]{typeName, branchIdList};
                        });
                        Iterator var13;
                        List subOid;
                        List subOids;
                        if (CollUtil.isNotEmpty(branchIdList)) {
                            subOids = CommonUtil.subObjectList(branchIdList, updateCount);
                            var13 = subOids.iterator();

                            while(var13.hasNext()) {
                                subOid = (List)var13.next();
                                this.typlmSubFolderService.updateObjDomainByTableAndBranchId(tableName, subOid, updateSubfolder.getDomainoid(), lockFlag);
                            }
                        } else if (CollUtil.isNotEmpty(oidList)) {
                            subOids = CommonUtil.subObjectList(oidList, updateCount);
                            var13 = subOids.iterator();

                            while(var13.hasNext()) {
                                subOid = (List)var13.next();
                                this.typlmSubFolderService.updateObjDomainByTableAndOid(tableName, subOid, updateSubfolder.getDomainoid());
                            }
                        }
                    }
                }

                sqlSession.commit();
            } catch (Throwable var22) {
                var5 = var22;
                throw var22;
            } finally {
                if (sqlSession != null) {
                    if (var5 != null) {
                        try {
                            sqlSession.close();
                        } catch (Throwable var21) {
                            var5.addSuppressed(var21);
                        }
                    } else {
                        sqlSession.close();
                    }
                }

            }
        }
    }

    private List<TableParamDTO> getTableParamDTOS() {
        List<TableParamDTO> tableParamDTOS = new ArrayList();
        List<Class<? extends CTyEntityBaseDO>> controllerOtypeList = this.typlmTypeExtService.getControllerOtypeList();
        TyplmLoggerUtil.debug(log, () -> {
            return "getTableParamDTOS，受文件夹管控的类controllerOtypeList= 【{}】";
        }, () -> {
            return new Object[]{controllerOtypeList};
        });
        Iterator var3 = controllerOtypeList.iterator();

        while(var3.hasNext()) {
            Class<? extends CTyEntityBaseDO> item = (Class)var3.next();
            if (TyEntityMapperUtil.checkEntityTableExistInSystem(item)) {
                TableParamDTO tableParamDTO = EntityBaseUtil.getTableParamDTO(item);
                tableParamDTOS.add(tableParamDTO);
            }
        }

        return tableParamDTOS;
    }

    private Map<String, List<CTyIterateBaseDO>> getLatestObjMap(List<BigInteger> idList, List<String> newPermissionList, List<TyBaseObject> objectList) {
        Map<String, List<CTyIterateBaseDO>> typeToIdMap = new HashMap();
        List<TableParamDTO> tableParamDTOS = this.getTableParamDTOS();
        TyplmLoggerUtil.debug(log, () -> {
            return "getLatestObjMap，受文件夹管控的表名tableParamDTOS= 【{}】";
        }, () -> {
            return new Object[]{tableParamDTOS};
        });
        if (CollUtil.isNotEmpty(idList) && CollUtil.isNotEmpty(tableParamDTOS)) {
            List<CTyIterateBaseDO> objList = this.typlmSubFolderService.getAllRevisionLatestObjListByFolderIds(idList, tableParamDTOS);
            TyplmLoggerUtil.debug(log, () -> {
                return "getLatestObjMap，查文件夹下对象大版本id,objList= 【{}】";
            }, () -> {
                return new Object[]{objList};
            });
            if (CollUtil.isNotEmpty(objList)) {
                Iterator var7 = objList.iterator();

                while(var7.hasNext()) {
                    CTyIterateBaseDO identifier = (CTyIterateBaseDO)var7.next();
                    if (typeToIdMap.containsKey(identifier.getOtype())) {
                        ((List)typeToIdMap.get(identifier.getOtype())).add(identifier);
                    } else {
                        List<CTyIterateBaseDO> list = new ArrayList();
                        list.add(identifier);
                        typeToIdMap.put(identifier.getOtype(), list);
                    }
                }

                var7 = typeToIdMap.entrySet().iterator();

                while(var7.hasNext()) {
                    Map.Entry<String, List<CTyIterateBaseDO>> entry = (Map.Entry)var7.next();
                    objectList.addAll(CommonUtil.getEntitys((String)entry.getKey(), (List)((List<CTyIterateBaseDO>)entry.getValue()).stream().map((e) -> {
                        return e.getOid().toString();
                    }).collect(Collectors.toList())));
                }

                int size = objectList.size() - newPermissionList.size();

                for(int i = 0; i < size; ++i) {
                    newPermissionList.add("更改域");
                }
            }
        }

        return typeToIdMap;
    }

    private void getSubfolderPermission(List<SubfolderDO> subfolderDOList, SubfolderDO subfolder, List<TyBaseObject> listObj, List<String> permissionList, String permissionName) {
        String newPermissionName = permissionName + "_" + "更改域";
        if (CollUtil.isNotEmpty(subfolderDOList)) {
            subfolderDOList.forEach((subfolderDO) -> {
                SubfolderDO subfold = new SubfolderDO();
                subfold.setOid(subfolderDO.getOid());
                subfold.setOtype(subfolder.getOtype());
                subfold.setName(subfolderDO.getName());
                subfold.setDomainoid(subfolder.getDomainoid());
                subfold.setDomainotype(subfolder.getDomainotype());
                listObj.add(subfold);
                permissionList.add(newPermissionName);
            });
        }

        permissionList.set(0, newPermissionName);
    }

    private void getSubfolderUpdateDomainPermission(SubfolderDO updateSubfolder, SubfolderDO subfolder, List<String> permissionList, List<TyBaseObject> listObj) {
        if (!updateSubfolder.getDomainoid().equals(subfolder.getDomainoid())) {
            int size = listObj.size();

            for(int i = 0; i < size; ++i) {
                TyBaseObject subfo = (TyBaseObject)listObj.get(i);
                Object clone = subfo.clone();
                if (clone instanceof SubfolderDO) {
                    SubfolderDO destSubFolder = (SubfolderDO)clone;
                    destSubFolder.setDomainoid(updateSubfolder.getDomainoid());
                    listObj.add(destSubFolder);
                    permissionList.add("通过移动创建");
                }
            }
        }

    }

    private void checkEnumListIgnoreCase(String key, String value, List<String> enumList) {
        if (StringUtils.isBlank(value)) {
            TyException.throwSingleTyExceptionArray(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{key});
        }

        long num = enumList.stream().filter((item) -> {
            return item.equalsIgnoreCase(value);
        }).count();
        if (num == 0L) {
            TyException.throwSingleTyExceptionArray(ResponseCodeEnum.ACC_PARAMETER_ENUM_NOT_CONTAINERS_ERROR, new String[]{key, value, StringUtils.join(enumList, ",")});
        }

    }

    private void modifyDomain(SubfolderWebVO subfolderWebVO, SubfolderDO subfolder, SubfolderDO updateSubfolder) {
        String isInheritedParent = subfolderWebVO.getIsInheritedParent();
        if (StringUtils.isNotBlank(isInheritedParent) && "Y".equalsIgnoreCase(isInheritedParent)) {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹为继承域。";
            });
            TyplmLoggerUtil.debug(log, () -> {
                return "getParentDomainBySubFolder 获取当前文件夹父域入参 folderOid:===>【{}】";
            }, () -> {
                return new Object[]{subfolder.getOid()};
            });
            DomainDO parentDomain = this.typlmSubFolderService.getParentDomainBySubFolder(subfolder.getOid());
            if (ObjectUtils.isEmpty(parentDomain)) {
                TyException.throwSingleTyExceptionArray(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"parentDomain:"});
            }

            updateSubfolder.setInheriteddomain(1L);
            updateSubfolder.setDomainoid(parentDomain.getOid());
            updateSubfolder.setDomainotype(parentDomain.getOtype());
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹不是继承域。";
            });
            updateSubfolder.setInheriteddomain(0L);
            String domainId = subfolderWebVO.getDomainId();
            String domainPath = subfolderWebVO.getDomainPath();
            if (StringUtils.isNotEmpty(domainPath)) {
                this.checkParamRepeatBlank(domainPath, "domainPath");
            }

            if (StringUtils.isEmpty(domainPath) && StringUtils.isNotEmpty(domainId)) {
                this.checkParamRepeatBlank(domainId, "domainId");
            }

            if (StringUtils.isBlank(domainId) && StringUtils.isBlank(domainPath)) {
                updateSubfolder.setDomainoid(subfolder.getDomainoid());
                updateSubfolder.setDomainotype(subfolder.getDomainotype());
            } else {
                TyplmLoggerUtil.debug(log, () -> {
                    return "getDomainByContainer 根据容器和域名称或者路径确认 containerOid:===>【{}】,containerOid:===>【{}】,containerOid:===>【{}】,containerOid:===>【{}】";
                }, () -> {
                    return new Object[]{subfolder.getContaineroid(), subfolder.getContainerotype(), domainPath, domainId};
                });
                DomainDO domainDO = this.typlmDomainService.getDomainByContainer(subfolder.getContaineroid(), subfolder.getContainerotype(), domainPath, domainId);
                if (domainDO.getContaineroid().equals(subfolder.getContaineroid()) && domainDO.getContainerotype().equals(subfolder.getContainerotype())) {
                    updateSubfolder.setDomainoid(domainDO.getOid());
                    updateSubfolder.setDomainotype(domainDO.getOtype());
                } else {
                    String containerName = this.typlmContainerService.getAllContainerName(subfolder.getContaineroid(), subfolder.getContainerotype());
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_DOMAIN_INFORMATION_NOTMATCH_CONTAINER_INFORMATION, new String[]{domainDO.getName(), containerName})));
                }
            }
        }
    }

    private void checkParamRepeatBlank(String param, String columnName) {
        if (param != null && !"".equals(param) && StringUtils.isBlank(param)) {
            boolean check = Pattern.compile("\\s+").matcher(param).find();
            if (check) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{columnName + ":" + param})));
            }
        }

    }

    private SubfolderDO validSubfolderWebVO(SubfolderWebVO subfolderWebVO) {
        if (Objects.isNull(subfolderWebVO)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"subfolderDO"})));
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹入参是否为空校验通过。";
            });
            this.validSubfolderId(subfolderWebVO.getOid());
            String folderName = subfolderWebVO.getName();
            if ("".equals(subfolderWebVO.getName())) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"name"})));
            } else if (StringUtils.isNotBlank(folderName) && folderName.contains("/")) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_CONTAINS_SPECIAL_CHARACTER, new String[]{folderName, "/"})));
            } else {
                TyplmLoggerUtil.debug(log, () -> {
                    return "文件夹入参名称格式校验通过,name：==>【{}】";
                }, () -> {
                    return new Object[]{folderName};
                });
                SubfolderDO subfolder = this.typlmSubFolderService.selectSubfolderDOByOid(new BigInteger(subfolderWebVO.getOid()));
                if (Objects.isNull(subfolder)) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{subfolderWebVO.getOid()})));
                } else {
                    TyplmLoggerUtil.debug(log, () -> {
                        return "文件夹存在性校验通过,subfolder:==>【{}】";
                    }, () -> {
                        return new Object[]{JSON.toJSONString(subfolder)};
                    });
                    if (this.isExistsSubfolder(subfolder, subfolderWebVO.getName())) {
                        throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_HAD_EXISTS, new String[]{subfolderWebVO.getName()})));
                    } else {
                        TyplmLoggerUtil.debug(log, () -> {
                            return "文件夹是否重名校验通过";
                        });
                        String isInheritedParent = subfolderWebVO.getIsInheritedParent();
                        if (StringUtils.isNotBlank(isInheritedParent)) {
                            this.checkEnumListIgnoreCase("isInheritedParent", isInheritedParent, Arrays.asList("Y", "N"));
                        }

                        TyplmLoggerUtil.debug(log, () -> {
                            return "文件夹继承域校验通过";
                        });
                        return subfolder;
                    }
                }
            }
        }
    }

    private boolean isExistsSubfolder(SubfolderDO subfolder, String folderName) {
        if (StringUtils.isBlank(folderName)) {
            return false;
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "isExistsSubfolder,subfolder：==>【{}】";
            }, () -> {
                return new Object[]{subfolder};
            });
            BigInteger parentId;
            String parentType;
            if (subfolder.getParentnodeoid() != null && subfolder.getParentnodeoid().intValue() != 0) {
                parentId = subfolder.getParentnodeoid();
                parentType = subfolder.getParentnodeotype();
            } else {
                parentId = subfolder.getCabinetoid();
                parentType = subfolder.getCabinetotype();
            }

            SubfolderDO folder = this.querySonFolderByParentAndSonName(parentId, parentType, folderName);
            TyplmLoggerUtil.debug(log, () -> {
                return "isExistsSubfolder,querySonFolderByParentAndSonName返回 ，folder：==>【{}】";
            }, () -> {
                return new Object[]{folder};
            });
            return folder != null && !folder.getOid().equals(subfolder.getOid());
        }
    }

    public SubfolderDO querySubFolderByOid(BigInteger oid) {
        SubfolderDO subfolderDO = null;
        if (!ObjectUtils.isEmpty(oid) && !BigInteger.ZERO.equals(oid)) {
            subfolderDO = this.typlmSubFolderService.selectSubfolderDOByOid(oid);
            return subfolderDO;
        } else {
            log.info("subfolder id is null");
            return subfolderDO;
        }
    }

    public SubfolderDetailVO getSubFolderDetail(String oid) {
        this.validSubfolderId(oid);
        SubfolderDetailVO subfolderDetailVO = this.typlmSubFolderService.querySubFolderDetailByOid(oid);
        TyplmLoggerUtil.debug(log, () -> {
            return "getSubFolderDetail,querySubFolderDetailByOid返回 ，subfolderDetailVO：==>【{}】";
        }, () -> {
            return new Object[]{subfolderDetailVO};
        });
        if (Objects.isNull(subfolderDetailVO)) {
            return SUBFOLDERDETAILVONULL;
        } else {
            SubfolderDO subfolderDO = new SubfolderDO();
            BeanUtils.copyProperties(subfolderDetailVO, subfolderDO);
            return this.typlmPermissionsUtil.checkPermissions(subfolderDO, "读取", CommonUtil.getUser().getOid()) ? subfolderDetailVO : SUBFOLDERDETAILVONULL;
        }
    }

    private void validSubfolderId(String oid) {
        if (StringUtils.isBlank(oid)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"id"})));
        } else if (!StringUtil.isDigits(oid)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"id", oid})));
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "oid 入参格式校验通过,oid==>【{}】";
            }, () -> {
                return new Object[]{oid};
            });
        }
    }

    public int deleteSubfolder(String oid, UserDO userDO) {
        this.validSubfolderId(oid);
        SubfolderDO subfolderDO = this.typlmSubFolderService.selectSubfolderDOByOid(new BigInteger(oid));
        if (Objects.isNull(subfolderDO)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{oid})));
        } else {
            this.typlmPermissionsUtil.checkObjectPermissionList(userDO, Collections.singletonList(subfolderDO), "删除");
            TyplmLoggerUtil.debug(log, () -> {
                return "deleteSubfolder 验证用户是否有删除文件夹权限成功";
            });
            this.validDeleteSubfolder(subfolderDO);
            TyplmLoggerUtil.debug(log, () -> {
                return "deleteSubfolder 验证判断是否有子文件成功";
            });
            this.deleteSubFolderLinkByBoid(subfolderDO.getOid(), subfolderDO.getOtype());
            TyplmLoggerUtil.debug(log, () -> {
                return "deleteSubfolder 删除文件夹关联关系成功";
            });
            return this.typlmSubFolderService.deleteSubfolderDOByOid(subfolderDO.getOid());
        }
    }

    private void validDeleteSubfolder(SubfolderDO subfolderDO) {
        List<SubfolderLinkDO> subfolderList = this.querySubfolderByAObj(subfolderDO.getOid(), subfolderDO.getOtype());
        if (!CollectionUtils.isEmpty(subfolderList)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_HAS_CHILD_CANNOT_DELETE, new String[]{subfolderDO.getName()})));
        } else {
            int count = this.typlmSubFolderService.queryObjCountByFolderId(subfolderDO.getOid().toString());
            if (count > 0) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_HAS_CHILD_CANNOT_DELETE, new String[]{subfolderDO.getName()})));
            }
        }
    }

    public int updateSubFolderByOid(SubfolderDO sdo) {
        if (ObjectUtils.isEmpty(sdo)) {
            log.info("subfolder id is null");
            return 0;
        } else if (this.isExistsSubfolder(sdo, sdo.getName())) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_HAD_EXISTS, new String[]{sdo.getName()})));
        } else {
            String permissionName = "修改_读取";
            SubfolderDO dbFolder = (SubfolderDO)this.typlmSubFolderService.querySubFolderByIds(Collections.singletonList(sdo.getOid())).get(0);
            if (StringUtils.isNotBlank(sdo.getName()) && !dbFolder.getName().equals(sdo.getName())) {
                permissionName = permissionName + "_修改标识";
            }

            this.typlmPermissionsUtil.checkObjectPermissionList(TyAccountContext.getUser(), Collections.singletonList(dbFolder), permissionName);
            return this.typlmSubFolderService.updateSubfolderDO(sdo);
        }
    }

    public String getPathByFolderOid(BigInteger id) {
        if (Objects.isNull(id)) {
            return "";
        } else {
            StringBuilder sb = new StringBuilder("");
            SubfolderDO folder = this.querySubFolderByOid(id);
            if (!ObjectUtils.isEmpty(folder) && folder.getOid().compareTo(BigInteger.ZERO) != 0) {
                sb.insert(0, folder.getName());
                return this.getParentFolder(folder, sb);
            } else {
                log.info("OID：" + id + " sufolder is not found");
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{String.valueOf(id)})));
            }
        }
    }

    public String getPathByCabinetOid(BigInteger id) {
        if (Objects.isNull(id)) {
            return "";
        } else {
            StringBuilder sb = new StringBuilder("");
            CabinetDO cabinetDO = this.typlmCabinetService.queryCabinetByOid(id);
            if (ObjectUtils.isEmpty(cabinetDO) || cabinetDO.getOid().compareTo(BigInteger.ZERO) == 0) {
                log.info("OID：" + id + " cabinet is not found");
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{id + ""});
            }

            String continerOtype = cabinetDO.getContainerotype();
            this.assembleData(sb, cabinetDO, continerOtype);
            return sb.toString();
        }
    }

    public String getParentFolder(SubfolderDO child, StringBuilder sb) {
        Example ex = new Example(SubfolderLinkDO.class, true, true);
        Example.Criteria criteria = ex.createCriteria();
        criteria.andEqualTo("boid", child.getOid());
        criteria.andEqualTo("botype", child.getOtype());
        List<SubfolderLinkDO> aListSubFolder = this.typlmSubfolderLinkMapper.selectByExample(ex);
        if (ObjectUtils.isNotEmpty(aListSubFolder)) {
            if (aListSubFolder.get(0) != null && "ty.inteplm.folder.CTySubFolder".equals(((SubfolderLinkDO)aListSubFolder.get(0)).getAotype())) {
                SubfolderDO parentFolder = this.querySubFolderByOid(((SubfolderLinkDO)aListSubFolder.get(0)).getAoid());
                sb.insert(0, "/");
                sb.insert(0, parentFolder.getName());
                this.getParentFolder(parentFolder, sb);
            }

            if (aListSubFolder.get(0) != null && "ty.inteplm.folder.CTyCabinet".equals(((SubfolderLinkDO)aListSubFolder.get(0)).getAotype())) {
                CabinetDO cabinet = (CabinetDO)this.typlmCabinetMapper.selectByPrimaryKey(((SubfolderLinkDO)aListSubFolder.get(0)).getAoid());
                String continerOtype = cabinet.getContainerotype();
                this.assembleData(sb, cabinet, continerOtype);
            }

            return sb.toString();
        } else {
            return "";
        }
    }

    private void assembleData(StringBuilder stringBuilder, CabinetDO cabinet, String continerOtype) {
        if (!StringUtils.isBlank(continerOtype)) {
            if (ContainerConstant.getContainerOtype().contains(continerOtype)) {
                Class<? extends CTyEntityBaseDO> aClass = TyEntityMapperUtil.getClassByOtype(continerOtype);
                Example example = new Example(aClass, true, true);
                Example.Criteria criteria = example.createCriteria();
                criteria.andEqualTo("defaultcabinetoid", cabinet.getOid());
                ITyplmContainerHelper iTyContainerHelper = (ITyplmContainerHelper)this.typlmInterfaceFactory.creatContainerInterfaceService(ITyplmContainerHelper.class, continerOtype);
                List<CTyEntityBaseDO> containerList = iTyContainerHelper.queryByCondition(example);
                this.getContainerNameStr(stringBuilder, containerList);
            } else {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_ENUM_ERROR, new String[]{String.join(",", ContainerConstant.getContainerOtype())});
            }

        }
    }

    private void getContainerNameStr(StringBuilder stringBuilder, List<? extends CTyEntityBaseDO> containerList) {
        if (ObjectUtils.isNotEmpty(containerList)) {
            stringBuilder.insert(0, "/");
            stringBuilder.insert(0, ((CTyEntityBaseDO)containerList.get(0)).getName());
        }

    }

    public SubfolderDO querySubFolderByFullPathAndParent(BigInteger cabinetOID, String cabinetOtype, String fullPath) {
        String[] folderPath = fullPath.split("/");
        List<String> folderList = Arrays.asList(folderPath);
        List<String> folders = (List)folderList.stream().filter(StringUtils::isNotEmpty).collect(Collectors.toList());
        SubfolderDO subfolderDO = null;

        try {
            subfolderDO = this.querySonFolderByParentAndSonName(cabinetOID, cabinetOtype, URLDecoder.decode((String)folders.get(0), StandardCharsets.UTF_8.name()));
            TyplmLoggerUtil.debug(log, () -> {
                return "根据文件柜和文件夹路径获取文件， folders， ==【{}】";
            }, () -> {
                return new Object[]{folders};
            });

            for(int i = 1; i < folders.size() && Objects.nonNull(subfolderDO); ++i) {
                subfolderDO = this.querySonFolderByParentAndSonName(subfolderDO.getOid(), subfolderDO.getOtype(), URLDecoder.decode((String)folders.get(i), StandardCharsets.UTF_8.name()));
            }
        } catch (UnsupportedEncodingException var9) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_FOLDER_NAME_DECODER_ERROR, new String[0]);
        }

        return subfolderDO;
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public List<String> insertFolderLinkAuthorityDomain(List<PermissionDomainDTO> params, UserDO user) {
        List<String> result = new ArrayList();
        Iterator var4 = params.iterator();

        while(var4.hasNext()) {
            PermissionDomainDTO dto = (PermissionDomainDTO)var4.next();
            DomainDO domainDO = this.typlmAuthorityDomainService.queryDomainByDomainPath(dto);
            if (domainDO == null) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{"domain:" + dto.getDomainName()})));
            }

            String folderName = dto.getFolderName();
            TyplmLoggerUtil.debug(log, () -> {
                return "insertFolderLinkAuthorityDomain，querySubFolderByFullPath入参， dto， ==【{}】";
            }, () -> {
                return new Object[]{dto};
            });
            SubfolderDO subfolderDO = this.querySubFolderByFullPath(dto.getContainerType(), dto.getContainerName(), folderName);
            if (subfolderDO == null) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{folderName})));
            }

            subfolderDO.setUpdatoroid(user.getOid());
            subfolderDO.setUpdatorotype(user.getOtype());
            TyplmEntityBaseUtil.fillCommonFieldForUpdate(subfolderDO);
            subfolderDO.setDomainoid(domainDO.getOid());
            subfolderDO.setDomainotype(domainDO.getOtype());
            result.add(StringUtil.trim(subfolderDO.getOid()));
            TyplmLoggerUtil.debug(log, () -> {
                return "insertFolderLinkAuthorityDomain，typlmSubFolderService入参， subfolderDO， ==【{}】";
            }, () -> {
                return new Object[]{subfolderDO};
            });
            this.typlmSubFolderService.updateSubfolderDO(subfolderDO);
        }

        return result;
    }

    public int updateSubfolderLinkDO(SubfolderLinkDO subfolderLinkDO) {
        TyplmEntityBaseUtil.fillCommonFieldForUpdate(subfolderLinkDO);
        return this.typlmSubfolderLinkMapper.updateByPrimaryKeySelective(subfolderLinkDO);
    }

    public int deleteSubfolderLinkDO(BigInteger oid) {
        return this.typlmSubfolderLinkMapper.deleteByPrimaryKey(oid);
    }

    public int deleteBySubfolderOids(List<BigInteger> aoids) {
        BatchQueryHelper.batchSplitDelete(aoids, this::metaBatchDeleteByAoids);
        return aoids.size();
    }

    private void metaBatchDeleteByAoids(Collection<BigInteger> aoids) {
        BatchQueryHelper.deleteExampleColumnIn(aoids, SubfolderDO.class, this.typlmSubfolderLinkMapper, "aoid");
    }

    public List<SubfolderLinkDO> selectSubfolderLinkDOList(SubfolderLinkDO subfolderLinkDO) {
        return this.typlmSubfolderLinkMapper.select(subfolderLinkDO);
    }

    public SubfolderLinkDO createSubfolderLinkWithoutCommit(CabinetDO defaultCabinetDO, SubfolderDO subfolderDO, UserDO userDO) {
        TyplmEntityBaseUtil.checkParamNotNull(defaultCabinetDO, "defaultCabinet");
        TyplmEntityBaseUtil.checkParamNotNull(subfolderDO, "subfolder");
        return this.newSubfolderLink(defaultCabinetDO.getIdentifierRef(), subfolderDO.getIdentifierRef(), userDO);
    }

    public String recursiveQueryFolderPath(String oid) {
        return this.recursiveQueryFolderPath(oid, false);
    }

    public String recursiveQueryFolderPath(String oid, boolean includeContainer) {
        String subFolderOidStr = !Objects.isNull(oid) && !"null".equals(oid) ? oid : "0";
        this.validSubfolderId(subFolderOidStr);
        Map<BigInteger, String> map = this.recursiveQueryFolderPathByIdList(Collections.singletonList(new BigInteger(subFolderOidStr)), includeContainer);
        return (String)((Map)ObjectUtils.defaultIfNull(map, new HashMap())).get(new BigInteger(subFolderOidStr));
    }

    public Map<BigInteger, String> recursiveQueryFolderPathByIdList(List<BigInteger> subFolderOidList) {
        return this.recursiveQueryFolderPathByIdList(subFolderOidList, false);
    }

    public Map<BigInteger, String> recursiveQueryFolderPathByIdList(List<BigInteger> paramOidList, boolean includeContainer) {
        List<BigInteger> subFolderOidList = (List)paramOidList.stream().map((item) -> {
            return (BigInteger)ObjectUtils.defaultIfNull(item, BigInteger.ZERO);
        }).distinct().collect(Collectors.toList());
        Map<BigInteger, String> resultMap = new HashMap();
        if (CollectionUtils.isEmpty(subFolderOidList)) {
            return resultMap;
        } else {
            List<SubFolderPathVO> subFolderPathVOS = this.typlmSubfolderLinkMapper.recursiveQueryFolderPathByidList(subFolderOidList, includeContainer);
            TyplmLoggerUtil.debug(log, () -> {
                return "recursiveQueryFolderPathByIdList，批量id递归查询文件夹路径返回， subFolderPathVOS， ==【{}】";
            }, () -> {
                return new Object[]{subFolderPathVOS};
            });
            if (ObjectUtils.isEmpty(subFolderPathVOS)) {
                this.fillParamToMap(subFolderOidList, resultMap);
                return resultMap;
            } else {
                Map<BigInteger, String> map = (Map)subFolderPathVOS.stream().filter(Objects::nonNull).distinct().collect(Collectors.toMap((item) -> {
                    return new BigInteger(item.getSubFolderId());
                }, SubFolderPathVO::getFolderPath, (value1, value2) -> {
                    return value1;
                }));
                this.fillParamToMap(subFolderOidList, map);
                return map;
            }
        }
    }

    private void fillParamToMap(List<BigInteger> subFolderOidList, Map<BigInteger, String> map) {
        if (subFolderOidList.contains(BigInteger.ZERO)) {
            map.put(BigInteger.ZERO, "/");
        }

        Set<BigInteger> oidList = map.keySet();
        subFolderOidList.stream().filter((item) -> {
            return !BigInteger.ZERO.equals(item) && !oidList.contains(item);
        }).forEach((item) -> {
            String var10000 = (String)map.put(item, "");
        });
    }

    public Map<BigInteger, SubFolderPathVO> batchQueryFolderPathVOByIdList(List<BigInteger> paramOidList) {
        return this.batchQueryFolderPathVOByIdList(paramOidList, false);
    }

    public SubfolderDO getSubfolderDO(BigInteger cabinetoid, String cabinetotype, String folderid, String folderPath) {
        TyplmLoggerUtil.debug(log, () -> {
            return "getSubfolderDO入参， folderid ==【{}】， folderPath ==【{}】";
        }, () -> {
            return new Object[]{folderid, folderPath};
        });
        SubfolderDO subfolderDO;
        if (StringUtils.isNotBlank(folderid)) {
            subfolderDO = this.querySubFolderByOid(new BigInteger(folderid));
            if (subfolderDO == null) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{folderid})));
            }
        } else {
            if (!StringUtils.isNotBlank(folderPath)) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"folderid,folderPath"})));
            }

            if (cabinetoid.compareTo(BigInteger.ZERO) == 0 || !StringUtils.isNotBlank(cabinetotype)) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"cabinetoid,cabinetotype"})));
            }

            subfolderDO = this.querySubFolderByFullPathAndParent(cabinetoid, cabinetotype, folderPath);
            if (subfolderDO == null) {
                this.throwSubFolderUnExistInContainerException(cabinetoid, cabinetotype, folderPath);
            }
        }

        return subfolderDO;
    }

    private void throwSubFolderUnExistInContainerException(BigInteger cabinetoid, String cabinetotype, String folderPath) {
        List<CabinetDO> cabinetDOList = this.typlmCabinetService.getCabinetListByIds(Collections.singletonList(cabinetoid));
        TyplmLoggerUtil.debug(log, () -> {
            return "throwSubFolderUnExistInContainerException,批量获取文件柜返回， cabinetDOList ==【{}】";
        }, () -> {
            return new Object[]{cabinetDOList};
        });
        if (ObjectUtils.isEmpty(cabinetDOList)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{cabinetotype + ":" + cabinetoid})));
        } else {
            CabinetDO cabinetDO = (CabinetDO)cabinetDOList.get(0);
            String containerName = this.typlmContainerService.getAllContainerName(cabinetDO.getContaineroid(), cabinetDO.getContainerotype());
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_CONTAINER_FOLDER_NOT_FOUND, new String[]{folderPath, containerName})));
        }
    }

    public CTyEntityBaseDO getCabinetOrSubFolderDO(BigInteger cabinetoid, String cabinetotype, String folderid, String folderName) {
        if (!this.isEmptyOid(folderid) || (!StringUtils.isNotBlank(folderName) || !"/".equals(folderName)) && !StringUtils.isBlank(folderName)) {
            if (StringUtils.isBlank(folderid) && StringUtils.isNotBlank(folderName)) {
                TyplmLoggerUtil.debug(log, () -> {
                    return "校验folderName格式是否合法， folderName ==【{}】";
                }, () -> {
                    return new Object[]{folderName};
                });
                this.checkFolderPathIsIegalized(folderName);
            }

            return this.getSubfolderDO(cabinetoid, cabinetotype, folderid, folderName);
        } else if (!cabinetoid.equals(BigInteger.ZERO) && !StringUtils.isBlank(cabinetotype)) {
            TyplmLoggerUtil.debug(log, () -> {
                return "queryCabinetByOid的入参， cabinetoid ==【{}】";
            }, () -> {
                return new Object[]{cabinetoid};
            });
            return this.typlmCabinetService.queryCabinetByOid(cabinetoid);
        } else {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"cabinetoid,cabinetotype"})));
        }
    }

    private boolean isEmptyOid(String oid) {
        return StringUtils.isBlank(oid) || "0".equals(oid) || "null".equalsIgnoreCase(oid);
    }

    private boolean checkFolderPathIsIegalized(String folderPath) {
        if (StringUtils.isBlank(folderPath)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"folderPath"})));
        } else {
            String regx = "(/)\\1{1,}";
            boolean matches = Pattern.compile(regx).matcher(folderPath).find();
            if (matches) {
                TyException.throwSingleTyExceptionArray(ResponseCodeEnum.BIZ_FOLDER_PATH_FORMAT_INCORRECT, new String[]{folderPath});
            }

            return true;
        }
    }

    public CTyEntityBaseDO getSubFolderOrCabinetByContainerAndFolderPath(String containerName, String containerType, String folderPath) {
        if (StringUtils.isBlank(containerName) || StringUtils.isBlank(containerType) || StringUtils.isBlank(folderPath)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"containerName,containerType,folderPath"});
        }

        ContainerVO containerVO = this.typlmContainerService.getContainerByTypeAndName(containerType, containerName);
        TyplmLoggerUtil.debug(log, () -> {
            return "根据容器名称和容器类型获取容器名称， containerVO ==【{}】";
        }, () -> {
            return new Object[]{containerVO};
        });
        if (Objects.isNull(containerVO)) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_CONTAINER_DOES_NOT_EXISTS_IN_THE_SYSTEM, new String[]{"containerName:" + containerName + ",containerType:" + containerType})));
        } else {
            String defaultCabinetOid = containerVO.getDefaultcabinetoid();
            String defaultCabinetOtype = containerVO.getDefaultcabinetotype();
            if (StringUtils.isBlank(defaultCabinetOid) || StringUtils.isBlank(defaultCabinetOtype) || !StringUtil.isDigits(defaultCabinetOid) || "0".equals(defaultCabinetOid)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_COMMON_OBJ_CABINET_EMPTY, new String[]{"containerName:" + containerName + ",containerType:" + containerType});
            }

            CTyEntityBaseDO entityBaseDO = this.getCabinetOrSubFolderDO(new BigInteger(defaultCabinetOid), defaultCabinetOtype, (String)null, folderPath);
            if (Objects.isNull(entityBaseDO) && "/".equals(folderPath)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_COMMON_OBJ_CABINET_EMPTY, new String[]{"containerName:" + containerName + ",containerType:" + containerType + ",folderPath:" + folderPath});
            }

            if (Objects.isNull(entityBaseDO)) {
                TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.BIZ_FOLDER_OBJECT_NOT_EXIST_IN_SYSTEM, new String[]{"containerName:" + containerName + ",containerType:" + containerType + ",folderPath:" + folderPath});
            }

            return entityBaseDO;
        }
    }

    public SubfolderDO getSubFolderByContainerAndFolderPath(String containerName, String containerType, String folderPath) {
        if (StringUtils.isNotBlank(folderPath) && "/".equals(folderPath)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_FORMAT_ERROR, new String[]{"folderPath", folderPath});
        }

        CTyEntityBaseDO entityBaseDO = this.getSubFolderOrCabinetByContainerAndFolderPath(containerName, containerType, folderPath);
        if (entityBaseDO instanceof SubfolderDO) {
            return (SubfolderDO)entityBaseDO;
        } else {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_IN_OBJECT, new String[]{folderPath, "containerName:" + containerName + ",containerType:" + containerType})));
        }
    }

    public List<FolderOrCabinetPathVo> getSubFolderOrCabinetPath(List<SubFolderOrCabinetDTO> subFolderOrCabinetDTOList) {
        TyplmLoggerUtil.debug(log, () -> {
            return "getSubFolderOrCabinetPath入参， subFolderOrCabinetDTOList ==【{}】";
        }, () -> {
            return new Object[]{subFolderOrCabinetDTOList};
        });
        List<FolderOrCabinetPathVo> result = new ArrayList();
        if (!CollectionUtils.isEmpty(subFolderOrCabinetDTOList)) {
            List<BigInteger> foderIds = (List)subFolderOrCabinetDTOList.stream().filter((dto) -> {
                return "ty.inteplm.folder.CTySubFolder".equals(dto.getOtype());
            }).map((dto) -> {
                return CommonUtil.stringToBigIntegers(dto.getOid());
            }).distinct().collect(Collectors.toList());
            List<FolderOrCabinetPathVo> folderPath = new ArrayList();
            if (!CollectionUtils.isEmpty(foderIds)) {
                Map<BigInteger, String> idAndfolderPathMap = this.recursiveQueryFolderPathByIdList(foderIds);
                if (!CollectionUtils.isEmpty(idAndfolderPathMap)) {
                    folderPath = (List)foderIds.stream().map((id) -> {
                        return new FolderOrCabinetPathVo(id.toString(), "ty.inteplm.folder.CTySubFolder", this.standarPath((String)idAndfolderPathMap.get(id)));
                    }).collect(Collectors.toList());
                }
            }

            List<BigInteger> cabinetIds = (List)subFolderOrCabinetDTOList.stream().filter((dto) -> {
                return "ty.inteplm.folder.CTyCabinet".equals(dto.getOtype());
            }).map((dto) -> {
                return CommonUtil.stringToBigIntegers(dto.getOid());
            }).distinct().collect(Collectors.toList());
            List<FolderOrCabinetPathVo> findedCabinetPath = new ArrayList();
            List<FolderOrCabinetPathVo> remindIdPath = new ArrayList();
            if (!CollectionUtils.isEmpty(cabinetIds)) {
                findedCabinetPath = this.typlmCabinetService.getCabinetPathByIds(cabinetIds);
                TyplmLoggerUtil.debug(log, () -> {
                    return "批量根据oid查询文件柜路径， cabinetIds ==【{}】";
                }, () -> {
                    return new Object[]{cabinetIds};
                });
                if (!CollectionUtils.isEmpty((Collection)findedCabinetPath)) {
                    List<BigInteger> findedIdVO = (List)((List<FolderOrCabinetPathVo>)findedCabinetPath).stream().map((pathVO) -> {
                        return new BigInteger(pathVO.getOid());
                    }).collect(Collectors.toList());
                    cabinetIds.removeAll(findedIdVO);
                    if (!CollectionUtils.isEmpty(cabinetIds)) {
                        remindIdPath = (List)cabinetIds.stream().map((id) -> {
                            return new FolderOrCabinetPathVo(id.toString(), "ty.inteplm.folder.CTyCabinet", "");
                        }).collect(Collectors.toList());
                    }
                }
            }

            result.addAll((Collection)folderPath);
            result.addAll((Collection)findedCabinetPath);
            result.addAll((Collection)remindIdPath);
        }

        return result;
    }

    private String standarPath(String path) {
        String resultPath = path;
        if (Objects.nonNull(path) && path.startsWith("/")) {
            resultPath = path.substring(1);
        }

        return resultPath;
    }

    public List<SubfolderLinkDO> querySubfolderByAObj(BigInteger oID, String oType) {
        Example ex = new Example(SubfolderLinkDO.class, true, true);
        Example.Criteria criteria = ex.createCriteria();
        criteria.andEqualTo("aoid", oID);
        criteria.andEqualTo("aotype", oType);
        return this.typlmSubfolderLinkMapper.selectByExample(ex);
    }

    public List<SubfolderLinkDO> querySubfolderByBObj(BigInteger oID, String oType) {
        Example ex = new Example(SubfolderLinkDO.class, true, true);
        Example.Criteria criteria = ex.createCriteria();
        criteria.andEqualTo("boid", oID);
        criteria.andEqualTo("botype", oType);
        return this.typlmSubfolderLinkMapper.selectByExample(ex);
    }

    public List<SubfolderLinkDO> querySubfolderByBObjList(List<BigInteger> idList, String oType) {
        Map<String, Object> equalParams = new HashMap();
        equalParams.put("botype", oType);
        return BatchQueryHelper.batchSplitQuery(idList, equalParams, this::metaBatchQueryListByParams);
    }

    private List<SubfolderLinkDO> metaBatchQueryListByParams(Collection<BigInteger> boids, Map<String, Object> equalParams) {
        return BatchQueryHelper.queryExampleColumnIn(boids, equalParams, SubfolderLinkDO.class, "boid", this.typlmSubfolderLinkMapper);
    }

    public List<IdentifierEntity> queryFolderListByParent(BigInteger subFolderOid, String otype) {
        List<IdentifierEntity> result = new ArrayList();
        if (StringUtils.isNoneBlank(new CharSequence[]{otype}) && ObjectUtils.isNotEmpty(subFolderOid)) {
            result = this.typlmSubfolderLinkMapper.queryFolderListByParent(subFolderOid, otype);
        }

        return (List)result;
    }

    public List<SubfolderWebVO> querySubFolderListAndCountByParent(BigInteger oid, String otype) {
        FolderEntityQuery folderEntityQuery = new FolderEntityQuery();
        folderEntityQuery.setFolderID(oid);
        folderEntityQuery.setFolderOtype(otype);
        folderEntityQuery.setShowAllViewVersion(this.showAllViewVersion);
        this.initQueryCondition(folderEntityQuery);
        List<SubfolderWebVO> subfolderWebVOS = this.typlmSubfolderLinkMapper.querySubfolderAndCountByParent(folderEntityQuery);
        TyplmLoggerUtil.debug(log, () -> {
            return "获取子文件夹并统计文件夹下对象数量， subfolderWebVOS ==【{}】";
        }, () -> {
            return new Object[]{subfolderWebVOS};
        });
        return this.resetLeaf(folderEntityQuery, subfolderWebVOS);
    }

    private List<SubfolderWebVO> resetLeaf(FolderEntityQuery folderEntityQuery, List<SubfolderWebVO> subfolderWebVOS) {
        if (!CollectionUtils.isEmpty(subfolderWebVOS)) {
            if (this.checkNodeIndex(subfolderWebVOS)) {
                subfolderWebVOS = this.typlmSubfolderLinkMapper.querySubfolderAndCountByParent(folderEntityQuery);
            }

            subfolderWebVOS.forEach((item) -> {
                if ("true".equals(item.getHasChildren())) {
                    item.setIsLeaf(false);
                }

            });
        }

        return subfolderWebVOS;
    }

    public List<SubfolderWebVO> querySubFolderListByParent(BigInteger oid, String otype) {
        FolderEntityQuery folderEntityQuery = new FolderEntityQuery();
        folderEntityQuery.setFolderID(oid);
        folderEntityQuery.setFolderOtype(otype);
        folderEntityQuery.setShowAllViewVersion(this.showAllViewVersion);
        this.initQueryCondition(folderEntityQuery);
        List<SubfolderWebVO> subfolderWebVOS = this.typlmSubfolderLinkMapper.querySubfolderByParent(folderEntityQuery);
        TyplmLoggerUtil.debug(log, () -> {
            return "获取子文件夹， subfolderWebVOS ==【{}】";
        }, () -> {
            return new Object[]{subfolderWebVOS};
        });
        return this.resetLeaf(folderEntityQuery, subfolderWebVOS);
    }

    private boolean checkNodeIndex(List<SubfolderWebVO> subfolderWebVOS) {
        boolean needRefresh = false;
        Map<String, Set<Integer>> map = new HashMap();
        Iterator var4 = subfolderWebVOS.iterator();

        while(var4.hasNext()) {
            SubfolderWebVO item = (SubfolderWebVO)var4.next();
            if (item.getNodeindex() <= 0) {
                needRefresh = true;
                break;
            }

            if (StringUtils.isEmpty(item.getParentnodeoid())) {
                item.setParentnodeoid("0");
            }

            Set<Integer> set = (Set)map.computeIfAbsent(item.getParentnodeoid(), (k) -> {
                return new HashSet();
            });
            if (!set.add(item.getNodeindex())) {
                needRefresh = true;
                break;
            }
        }

        if (needRefresh) {
            this.restNodeIndex(subfolderWebVOS);
            return true;
        } else {
            return false;
        }
    }

    private void restNodeIndex(List<SubfolderWebVO> subfolderWebVOS) {
        Map<String, List<SubfolderWebVO>> listMap = (Map)subfolderWebVOS.stream().collect(Collectors.groupingBy(SubfolderWebVO::getParentnodeoid));
        List<SubfolderWebVO> updateList = new ArrayList();
        Iterator var4 = listMap.entrySet().iterator();

        List update;
        while(var4.hasNext()) {
            Map.Entry<String, List<SubfolderWebVO>> entry = (Map.Entry)var4.next();
            update = (List)entry.getValue();

            for(int i = 0; i < update.size(); ++i) {
                SubfolderWebVO entity = (SubfolderWebVO)update.get(i);
                int nodeIndex = i + 1;
                if (entity.getNodeindex() != nodeIndex) {
                    entity.setNodeindex(nodeIndex);
                    updateList.add(entity);
                }
            }
        }

        TyplmLoggerUtil.debug(log, () -> {
            return "restNodeIndex的参数， updateList ==【{}】";
        }, () -> {
            return new Object[]{updateList};
        });
        if (!CollectionUtils.isEmpty(updateList)) {
            List<List<SubfolderWebVO>> list = CommonUtil.subObjectList(updateList, 500);
            Iterator var11 = list.iterator();

            while(var11.hasNext()) {
                update = (List)var11.next();
                this.typlmSubfolderLinkMapper.updateFolderNodeIndex(update);
            }

        }
    }

    public QuerySubFolderOutDTO querySubFolderInfoByContainer(IdentifierEntity containerEntity) {
        CommonUtil.checkIdentifierNotNull(containerEntity);
        CTyEntityBaseDO containerObj = CommonUtil.getEntity(containerEntity);
        TyplmLoggerUtil.debug(log, () -> {
            return "querySubFolderInfoByContainer的参数， containerObj ==【{}】";
        }, () -> {
            return new Object[]{containerObj};
        });
        BigInteger defaultCabinetOid;
        String defaultCabinetOtype;
        if (!(containerObj instanceof CabinetDO) && !(containerObj instanceof SubfolderDO)) {
            if (!(containerObj instanceof ITyCabined)) {
                return new QuerySubFolderOutDTO();
            }

            defaultCabinetOid = ((ITyCabined)containerObj).getDefaultcabinetoid();
            defaultCabinetOtype = ((ITyCabined)containerObj).getDefaultcabinetotype();
        } else {
            defaultCabinetOid = containerObj.getOid();
            defaultCabinetOtype = containerObj.getOtype();
        }

        SubfolderDTO subfolderDTO = new SubfolderDTO();
        subfolderDTO.setOid(defaultCabinetOid);
        subfolderDTO.setOtype(defaultCabinetOtype);
        QuerySubFolderOutDTO querySubFolderOutDTO = new QuerySubFolderOutDTO();
        querySubFolderOutDTO.setContainerName(containerObj.getName());
        List<SubfolderWebVO> allSubFolderList = this.getAllSubFolderByParent(subfolderDTO);
        querySubFolderOutDTO.setDataList(allSubFolderList);
        List<SubfolderWebVO> subTreeList = this.buildFolderTree(subfolderDTO.getOid().toString(), allSubFolderList);
        SubfolderWebVO containerInfo = this.folderInfoAppendContainer(containerObj, subTreeList);
        querySubFolderOutDTO.setTreeList(Collections.singletonList(containerInfo));
        this.dealFolderPath(containerInfo, containerInfo.getChildList());
        return querySubFolderOutDTO;
    }

    private void dealFolderPath(SubfolderWebVO parent, List<SubfolderWebVO> children) {
        if (parent != null && !CollectionUtils.isEmpty(children)) {
            Iterator var3 = children.iterator();

            while(var3.hasNext()) {
                SubfolderWebVO child = (SubfolderWebVO)var3.next();
                child.setFolderPath(parent.getFolderPath() + "/" + child.getName());
                child.setFolderOidPath(parent.getFolderOidPath() + "/" + child.getOid());
                if (!CollectionUtils.isEmpty(child.getChildList())) {
                    this.dealFolderPath(child, child.getChildList());
                }
            }

        }
    }

    private List<SubfolderWebVO> getAllSubFolderByParent(SubfolderDTO subfolderDTO) {
        List<SubfolderWebVO> subfolderWebVOS = this.getAllSubFolderList(subfolderDTO);
        if (ObjectUtils.isEmpty(subfolderWebVOS)) {
            return Collections.emptyList();
        } else {
            if (this.checkNodeIndex(subfolderWebVOS)) {
                subfolderWebVOS = this.getAllSubFolderList(subfolderDTO);
            }

            this.resetSubCountInfo(subfolderWebVOS, subfolderDTO);
            this.resetPathInfo(subfolderWebVOS, subfolderDTO);
            this.resetLeafInfo(subfolderWebVOS);
            return subfolderWebVOS;
        }
    }

    private void resetSubCountInfo(List<SubfolderWebVO> subfolderWebVOS, SubfolderDTO subfolderDTO) {
        if (Boolean.TRUE.equals(subfolderDTO.getIsHaveCount())) {
            this.restCount(subfolderWebVOS, subfolderDTO);
        }

    }

    private List<SubfolderWebVO> getAllSubFolderList(SubfolderDTO subfolderDTO) {
        List<SubfolderWebVO> subfolderWebVOS = this.typlmSubfolderLinkMapper.queryAllSubfolderByParent(subfolderDTO.getOid(), subfolderDTO.getOtype());
        return ObjectUtils.isEmpty(subfolderWebVOS) ? Collections.emptyList() : subfolderWebVOS;
    }

    private void restCount(List<SubfolderWebVO> subfolderWebVOS, SubfolderDTO subfolderDTO) {
        FolderEntityQuery folderEntityQuery = new FolderEntityQuery();
        folderEntityQuery.setFolderID(subfolderDTO.getOid());
        folderEntityQuery.setFolderOtype(subfolderDTO.getOtype());
        folderEntityQuery.setShowAllViewVersion(this.showAllViewVersion);
        this.initQueryCondition(folderEntityQuery);
        List<BigInteger> oids = (List)subfolderWebVOS.stream().map(SubfolderWebVO::getOid).map(BigInteger::new).collect(Collectors.toList());
        folderEntityQuery.setSubFolderOidList(oids);
        List<SubfolderWebVO> countVO = this.typlmSubfolderLinkMapper.querySubfolderObjCount(folderEntityQuery);
        Map<String, Long> map = (Map)countVO.stream().filter(Objects::nonNull).distinct().collect(Collectors.toMap(SubfolderWebVO::getOid, SubfolderWebVO::getTotal, (value1, value2) -> {
            return value1;
        }));
        Iterator var7 = subfolderWebVOS.iterator();

        while(var7.hasNext()) {
            SubfolderWebVO subfolderWebVO = (SubfolderWebVO)var7.next();
            subfolderWebVO.setTotal(Objects.nonNull(map.get(subfolderWebVO.getOid())) ? (Long)map.get(subfolderWebVO.getOid()) : 0L);
        }

    }

    private void resetLeafInfo(List<SubfolderWebVO> subfolderWebVOS) {
        subfolderWebVOS.forEach((item) -> {
            if ("true".equals(item.getHasChildren())) {
                item.setIsLeaf(false);
            }

        });
    }

    private void resetPathInfo(List<SubfolderWebVO> subfolderWebVOS, SubfolderDTO subfolderDTO) {
        if (Boolean.TRUE.equals(subfolderDTO.getIsHavePath())) {
            Map<BigInteger, SubFolderPathVO> pathMap = this.batchQueryFolderPathVOByIdList((List)subfolderWebVOS.stream().map(SubfolderWebVO::getOid).map(BigInteger::new).distinct().collect(Collectors.toList()), true);
            Iterator var4 = subfolderWebVOS.iterator();

            while(var4.hasNext()) {
                SubfolderWebVO subfolderWebVO = (SubfolderWebVO)var4.next();
                SubFolderPathVO subFolderPathVO = (SubFolderPathVO)pathMap.get(new BigInteger(subfolderWebVO.getOid()));
                if (!Objects.isNull(subFolderPathVO)) {
                    subfolderWebVO.setFolderPath(subFolderPathVO.getFolderPath());
                    String realOidPath = this.getRealOidPath(subFolderPathVO.getPathId());
                    subfolderWebVO.setFolderOidPath(realOidPath);
                }
            }
        }

    }

    private String getRealOidPath(String oidPath) {
        String[] oidArray = StringUtils.split(oidPath, "/");
        if (ObjectUtils.isEmpty(oidArray)) {
            return "";
        } else {
            String[] containerArray = StringUtils.split(oidArray[0], ":");
            if (ObjectUtils.isEmpty(containerArray)) {
                return "";
            } else if (containerArray.length == 1) {
                return containerArray[0];
            } else {
                oidArray[0] = containerArray[1];
                return "/" + String.join("/", oidArray);
            }
        }
    }

    private List<SubfolderWebVO> buildFolderTree(String parentOid, List<SubfolderWebVO> subfolderWebVOS) {
        Map<String, List<SubfolderWebVO>> parentToChildList = new HashMap();
        Iterator var4 = subfolderWebVOS.iterator();

        while(var4.hasNext()) {
            SubfolderWebVO webVO = (SubfolderWebVO)var4.next();
            String parentnodeoid = webVO.getParentnodeoid();
            if (Objects.isNull(parentnodeoid)) {
                parentnodeoid = parentOid;
            }

            List<SubfolderWebVO> childList = (List)parentToChildList.computeIfAbsent(parentnodeoid, (k) -> {
                return new ArrayList();
            });
            childList.add(webVO);
        }

        List<SubfolderWebVO> resultList = (List)parentToChildList.getOrDefault(parentOid, new ArrayList());
        this.dealSubList(resultList, parentToChildList);
        return resultList;
    }

    private void dealSubList(List<SubfolderWebVO> list, Map<String, List<SubfolderWebVO>> parentToChildList) {
        Iterator var3 = list.iterator();

        while(var3.hasNext()) {
            SubfolderWebVO entity = (SubfolderWebVO)var3.next();
            List<SubfolderWebVO> childList = (List)parentToChildList.getOrDefault(entity.getOid(), new ArrayList());
            entity.setChildList(childList);
            if (!CollectionUtils.isEmpty(childList)) {
                this.dealSubList(childList, parentToChildList);
            }
        }

    }

    private SubfolderWebVO folderInfoAppendContainer(CTyEntityBaseDO containerObj, List<SubfolderWebVO> allSubFolderList) {
        SubfolderWebVO subfolderWebVO = new SubfolderWebVO();
        subfolderWebVO.setOid(String.valueOf(containerObj.getOid()));
        subfolderWebVO.setOtype(containerObj.getOtype());
        subfolderWebVO.setName(containerObj.getName());
        if (containerObj instanceof ITyContained) {
            subfolderWebVO.setContaineroid(String.valueOf(((ITyContained)containerObj).getContaineroid()));
            subfolderWebVO.setContainerotype(((ITyContained)containerObj).getContainerotype());
        }

        if (containerObj instanceof ITyDomainAdministratored) {
            subfolderWebVO.setDomainId(String.valueOf(((ITyDomainAdministratored)containerObj).getDomainoid()));
            subfolderWebVO.setDomainotype(((ITyDomainAdministratored)containerObj).getDomainotype());
        }

        if (ObjectUtils.isEmpty(allSubFolderList)) {
            subfolderWebVO.setIsLeaf(true);
        } else {
            subfolderWebVO.setHasChildren("true");
        }

        subfolderWebVO.setFolderPath("/" + containerObj.getName());
        subfolderWebVO.setFolderOidPath("/" + containerObj.getOid());
        subfolderWebVO.setChildList(allSubFolderList);
        return subfolderWebVO;
    }

    public Map<BigInteger, SubFolderPathVO> batchQueryFolderPathVOByIdList(List<BigInteger> paramOidList, boolean includeContainer) {
        List<BigInteger> subFolderOidList = (List)paramOidList.stream().map((item) -> {
            return (BigInteger)ObjectUtils.defaultIfNull(item, BigInteger.ZERO);
        }).distinct().collect(Collectors.toList());
        Map<BigInteger, SubFolderPathVO> resultMap = new HashMap();
        if (CollectionUtils.isEmpty(paramOidList)) {
            this.fillParamToMapPathVO(subFolderOidList, resultMap);
            return resultMap;
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "batchQueryFolderPathVOByIdList的参数， subFolderOidList ==【{}】";
            }, () -> {
                return new Object[]{subFolderOidList};
            });
            TyplmLoggerUtil.debug(log, () -> {
                return "batchQueryFolderPathVOByIdList的参数， includeContainer ==【{}】";
            }, () -> {
                return new Object[]{includeContainer};
            });
            List<SubFolderPathVO> subFolderPathVOS = BatchQueryHelper.batchSplitQuery(subFolderOidList, includeContainer, this.typlmSubfolderLinkMapper::recursiveQueryFolderPathByidList, false);
            if (CollectionUtils.isEmpty(subFolderPathVOS)) {
                this.fillParamToMapPathVO(subFolderOidList, resultMap);
                return resultMap;
            } else {
                Map<BigInteger, SubFolderPathVO> map = (Map)subFolderPathVOS.stream().filter(Objects::nonNull).distinct().collect(Collectors.toMap((item) -> {
                    return new BigInteger(item.getSubFolderId());
                }, Function.identity(), (value1, value2) -> {
                    return value1;
                }));
                this.fillParamToMapPathVO(subFolderOidList, map);
                return map;
            }
        }
    }

    public List<SubfolderLinkDO> changeSubFolderNodeIndex(MoveFolderDTO moveFolderDTO) {
        SubfolderWebVO sourceFolder = moveFolderDTO.getSourceFolder();
        SubfolderWebVO targetFolder = moveFolderDTO.getTargetFolder();
        List<SubfolderLinkDO> subfolderLinkDOS = this.checkSubFolder(sourceFolder, targetFolder);
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-文件夹校验通过";
        });
        Map<BigInteger, List<SubfolderLinkDO>> mapGroupByBOID = (Map)subfolderLinkDOS.stream().collect(Collectors.groupingBy(SubfolderLinkDO::getBoid));
        SubfolderLinkDO source = (SubfolderLinkDO)((List)mapGroupByBOID.get(new BigInteger(sourceFolder.getOid()))).get(0);
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-数据库中源对象信息, source ==>【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(source)};
        });
        SubfolderLinkDO target = (SubfolderLinkDO)((List)mapGroupByBOID.get(new BigInteger(targetFolder.getOid()))).get(0);
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-数据库中目标对象信息, target ==>【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(target)};
        });
        List<SubfolderLinkDO> sortList = this.typlmSubfolderLinkMapper.querySubFolderLinkByAoidAndSortRange(source.getAoid(), Math.min(source.getNodeindex(), target.getNodeindex()), Math.max(source.getNodeindex(), target.getNodeindex()));
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-需要修改位置索引的文件夹数量, size ==>【{}】";
        }, () -> {
            return new Object[]{sortList.size()};
        });
        source.setNodeindex(target.getNodeindex());
        List<SubfolderLinkDO> waitingSortDOList = (List)sortList.stream().filter((subfolderLinkDO) -> {
            return !subfolderLinkDO.getOid().equals(source.getOid());
        }).sorted(Comparator.comparing(SubfolderLinkDO::getNodeindex)).collect(Collectors.toList());
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-剩余待重新排序的文件夹数量, size ==>【{}】";
        }, () -> {
            return new Object[]{waitingSortDOList.size()};
        });
        List<Long> waitingIndex = (List)sortList.stream().map(SubfolderLinkDO::getNodeindex).filter((nodeIndex) -> {
            return !nodeIndex.equals(target.getNodeindex());
        }).sorted().collect(Collectors.toList());
        TyplmLoggerUtil.debug(log, () -> {
            return "移动文件夹-剩余待重新排序的索引数量, size ==>【{}】";
        }, () -> {
            return new Object[]{waitingIndex.size()};
        });

        for(int i = 0; i < waitingSortDOList.size(); ++i) {
            ((SubfolderLinkDO)waitingSortDOList.get(i)).setNodeindex((Long)waitingIndex.get(i));
        }

        waitingSortDOList.add(source);
        this.typlmEntityBaseService.batchUpdateWithCommit(waitingSortDOList, Boolean.TRUE);
        return waitingSortDOList;
    }

    public SubfolderWebVO createSubfolder(SubfolderVO subfolder) {
        UserDO userDO = CommonUtil.getUser();
        SubfolderDO subfolderDO = this.createSubfolder(subfolder, userDO);
        SubfolderWebVO subfolderWeb = new SubfolderWebVO();
        if (ObjectUtils.isNotEmpty(subfolderDO)) {
            subfolderDO.setName(subfolder.getName() + "(" + 0 + ")");
            subfolderWeb = (SubfolderWebVO)BeanUtil.copyProperties(subfolderDO, SubfolderWebVO.class, new String[0]);
        }

        return subfolderWeb;
    }
    public SubfolderWebVO createSubfolderByAdmin(SubfolderVO subfolder) {
        TyplmUserService typlmUserService= SpringUtil.getBean(TyplmUserService.class);
        UserDO userDO = typlmUserService.queryUserByName("admin");

        SubfolderDO subfolderDO = this.createSubfolder(subfolder, userDO);
        SubfolderWebVO subfolderWeb = new SubfolderWebVO();
        if (ObjectUtils.isNotEmpty(subfolderDO)) {
            subfolderDO.setName(subfolder.getName() + "(" + 0 + ")");
            subfolderWeb = (SubfolderWebVO)BeanUtil.copyProperties(subfolderDO, SubfolderWebVO.class, new String[0]);
        }

        return subfolderWeb;
    }
    public SubfolderDO createSubfolder(SubfolderVO subfolderVO, UserDO userDO) {
        BigInteger parentId = new BigInteger(subfolderVO.getParentOid());
        TyplmLoggerUtil.debug(log, () -> {
            return "querySonFolderByParentAndSonName的入参oid:==>【{}】, otype:==>【{}】, sonName:==>【{}】";
        }, () -> {
            return new Object[]{parentId, subfolderVO.getParentOtype(), subfolderVO.getName()};
        });
        SubfolderDO subfolder = this.querySonFolderByParentAndSonName(parentId, subfolderVO.getParentOtype(), subfolderVO.getName());
        if (subfolder != null) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_FOLDER_HAD_EXISTS, new String[]{subfolderVO.getName()})));
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹存在性校验通过!";
            });
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹父节点的类型 parentOtype：==> 【{}】";
            }, () -> {
                return new Object[]{subfolderVO.getParentOtype()};
            });
            if ("ty.inteplm.folder.CTyCabinet".equalsIgnoreCase(subfolderVO.getParentOtype())) {
                CabinetDO cabinetDO = (CabinetDO)this.typlmCabinetMapper.selectByPrimaryKey(new BigInteger(subfolderVO.getParentOid()));
                if (cabinetDO == null) {
                    throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{TyplmEntityBaseUtil.getOtypeDisplayName(subfolderVO.getParentOtype()) + ":" + subfolderVO.getParentOid()})));
                } else {
                    TyplmLoggerUtil.debug(log, () -> {
                        return "父节点文件柜 cabinetDO：==> 【{}】";
                    }, () -> {
                        return new Object[]{JSON.toJSONString(cabinetDO)};
                    });
                    Object copyObj = cabinetDO.clone();
                    if (StringUtils.isNotEmpty(subfolderVO.getDomainOid())) {
                        cabinetDO.setDomainoid(new BigInteger(subfolderVO.getDomainOid()));
                        cabinetDO.setDomainotype(subfolderVO.getDomainOtype());
                    }

                    SubfolderDO subfolderDO = this.setSubfolderDO(cabinetDO, (SubfolderDO)null, subfolderVO.getName(), userDO);
                    if (copyObj instanceof TyBaseObject) {
                        this.checkPermission((TyBaseObject)copyObj, subfolderDO, userDO);
                    }

                    String inheriteddomain = subfolderVO.getIsInheritedParent();
                    subfolderDO.setInheriteddomain(StringUtils.isBlank(inheriteddomain) ? 1L : Long.parseLong(inheriteddomain));
                    subfolderDO.setDescription(subfolderVO.getDescription());
                    subfolderDO.setParentnodeoid(BigInteger.ZERO);
                    subfolderDO.setParentnodeotype("ty.inteplm.folder.CTySubFolder");
                    this.fillsubfolderDO(subfolderVO, subfolderDO);
                    TyplmLoggerUtil.debug(log, () -> {
                        return "文件夹数据写入数据库 subfolderDO：==> 【{}】";
                    }, () -> {
                        return new Object[]{JSON.toJSONString(subfolderDO)};
                    });
                    this.typlmSubFolderService.insertSubfolderDO(subfolderDO);
                    BigInteger parentSubfolderId = new BigInteger(subfolderVO.getParentOid());
                    this.insertSubFolderLink(parentSubfolderId, subfolderVO.getParentOtype(), subfolderDO.getOid(), userDO.getOid());
                    return subfolderDO;
                }
            } else {
                return "ty.inteplm.folder.CTySubFolder".equalsIgnoreCase(subfolderVO.getParentOtype()) ? this.getNewSubFolder(subfolderVO, userDO) : SUBFOLDERDONULL;
            }
        }
    }

    public int insertSubFolderLink(BigInteger parentId, String parentType, BigInteger folderId, BigInteger userId) {
        SubfolderLinkDO link = new SubfolderLinkDO();
        link.setAoid(parentId);
        link.setAotype(parentType);
        link.setBoid(folderId);
        link.setBotype("ty.inteplm.folder.CTySubFolder");
        link.setCreatoroid(userId);
        link.setCreatorotype("ty.inteplm.org.CTyUser");
        link.setOid(this.snowflakeIdComponent.getInstance().nextId());
        link.setOtype("ty.inteplm.folder.CTySubFolderLink");
        List<SubfolderLinkDO> subfolderLinkDOS = this.querySubfolderByAObj(parentId, parentType);
        if (CollUtil.isNotEmpty(subfolderLinkDOS)) {
            long maxNodeIndex = (Long)subfolderLinkDOS.stream().filter((index) -> {
                return Objects.nonNull(index.getNodeindex());
            }).map(SubfolderLinkDO::getNodeindex).reduce(Long::max).orElse(0L);
            link.setNodeindex(++maxNodeIndex);
        } else {
            link.setNodeindex(1L);
        }

        EntityBaseUtil.fillCommonFieldForCreate(link);
        TyplmLoggerUtil.debug(log, () -> {
            return "文件夹关系数据写入数据库 SubfolderLinkDO：==> 【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(link)};
        });
        return this.typlmSubfolderLinkMapper.insert(link);
    }

    private SubfolderDO getNewSubFolder(SubfolderVO subfolderVO, UserDO userDO) {
        SubfolderDO parentSubfolderDO = this.typlmSubFolderService.selectSubfolderDOByOid(new BigInteger(subfolderVO.getParentOid()));
        if (parentSubfolderDO == null) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{TyplmEntityBaseUtil.getOtypeDisplayName(subfolderVO.getParentOtype()) + ":" + subfolderVO.getParentOid()})));
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "父节点文件夹 subfolderDO：==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(parentSubfolderDO)};
            });
            Object copyObj = parentSubfolderDO.clone();
            if (StringUtils.isNotEmpty(subfolderVO.getDomainOid())) {
                parentSubfolderDO.setDomainoid(new BigInteger(subfolderVO.getDomainOid()));
                parentSubfolderDO.setDomainotype("ty.inteplm.domain.CTyDomain");
            }

            SubfolderDO subfolderDO = this.setSubfolderDO((CabinetDO)null, parentSubfolderDO, subfolderVO.getName(), userDO);
            if (copyObj instanceof TyBaseObject) {
                this.checkPermission((TyBaseObject)copyObj, subfolderDO, userDO);
            }

            subfolderDO.setParentnodeoid(new BigInteger(subfolderVO.getParentOid()));
            subfolderDO.setParentnodeotype(subfolderVO.getParentOtype());
            subfolderDO.setDescription(subfolderVO.getDescription());
            this.fillsubfolderDO(subfolderVO, subfolderDO);
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹数据写入数据库 subfolderDO：==> 【{}】";
            }, () -> {
                return new Object[]{JSON.toJSONString(subfolderDO)};
            });
            this.typlmSubFolderService.insertSubfolderDO(subfolderDO);
            BigInteger parentOid = new BigInteger(subfolderVO.getParentOid());
            this.insertSubFolderLink(parentOid, subfolderVO.getParentOtype(), subfolderDO.getOid(), userDO.getOid());
            return subfolderDO;
        }
    }

    private void fillsubfolderDO(SubfolderVO subfolderVO, SubfolderDO subfolderDO) {
        String inheriteddomain = subfolderVO.getIsInheritedParent();
        subfolderDO.setInheriteddomain(StringUtils.isBlank(inheriteddomain) ? 1L : Long.parseLong(inheriteddomain));
    }

    private void checkPermission(TyBaseObject parent, SubfolderDO subfolderDO, UserDO userDO) {
        List<TyBaseObject> tyBaseObjects = new ArrayList();
        List<String> permissionList = new ArrayList();
        tyBaseObjects.add(0, parent);
        permissionList.add(0, "修改_读取");
        tyBaseObjects.add(1, subfolderDO);
        permissionList.add(1, "创建");
        this.typlmPermissionsUtil.checkObjectPermission(userDO, tyBaseObjects, permissionList);
    }

    private SubfolderDO setSubfolderDO(CabinetDO cabinetDO, SubfolderDO subfolderDO, String subfolderName, UserDO userDO) {
        SubfolderDO subfolder = new SubfolderDO();
        subfolder.setOid(this.snowflakeIdComponent.getInstance().nextId());
        subfolder.setOtype("ty.inteplm.folder.CTySubFolder");
        subfolder.setName(subfolderName);
        if (Objects.nonNull(cabinetDO)) {
            subfolder.setCabinetoid(cabinetDO.getOid());
            subfolder.setContaineroid(cabinetDO.getContaineroid());
            subfolder.setCabinetotype(cabinetDO.getOtype());
            subfolder.setContainerotype(cabinetDO.getContainerotype());
            subfolder.setDomainoid(cabinetDO.getDomainoid());
            subfolder.setDomainotype(cabinetDO.getDomainotype());
            subfolder.setCreatoroid(userDO.getOid());
            subfolder.setCreatorotype(userDO.getOtype());
            subfolder.setOwneroid(userDO.getOid());
            subfolder.setOwnerotype(userDO.getOtype());
            subfolder.setUpdatoroid(userDO.getOid());
            subfolder.setUpdatorotype(userDO.getOtype());
        } else {
            if (Objects.nonNull(subfolderDO)) {
                subfolder.setCabinetoid(subfolderDO.getCabinetoid());
                subfolder.setCabinetotype(subfolderDO.getCabinetotype());
                subfolder.setContaineroid(subfolderDO.getContaineroid());
                subfolder.setContainerotype(subfolderDO.getContainerotype());
                subfolder.setDomainoid(subfolderDO.getDomainoid());
                subfolder.setDomainotype(subfolderDO.getDomainotype());
            }

            subfolder.setCreatoroid(userDO.getOid());
            subfolder.setCreatorotype(userDO.getOtype());
            subfolder.setUpdatoroid(userDO.getOid());
            subfolder.setUpdatorotype(userDO.getOtype());
            subfolder.setOwneroid(userDO.getOid());
            subfolder.setOwnerotype(userDO.getOtype());
        }

        return subfolder;
    }

    private SubfolderDO querySonFolderByParentAndSonName(BigInteger oid, String otype, String sonName) {
        return this.typlmSubFolderService.querySubfolderDOByParentIdAndName(oid, otype, sonName);
    }

    private List<SubfolderLinkDO> checkSubFolder(SubfolderWebVO sourceFolder, SubfolderWebVO targetFolder) {
        List<BigInteger> linkOIDList = Arrays.asList(sourceFolder.getLinkOid(), targetFolder.getLinkOid());
        TyplmLoggerUtil.debug(log, () -> {
            return "querySubFolderLinkByOids的入参oids：==>【{}】";
        }, () -> {
            return new Object[]{JSON.toJSONString(linkOIDList)};
        });
        List<SubfolderLinkDO> subfolderLinkDOS = this.typlmSubfolderLinkMapper.querySubFolderLinkByOids(linkOIDList);
        boolean sourceFolderExist = subfolderLinkDOS.stream().anyMatch((subfolderLinkDO) -> {
            return subfolderLinkDO.getOid().equals(sourceFolder.getLinkOid()) && subfolderLinkDO.getBoid().equals(new BigInteger(sourceFolder.getOid()));
        });
        if (!sourceFolderExist) {
            throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{sourceFolder.getLinkOid().toString()})));
        } else {
            TyplmLoggerUtil.debug(log, () -> {
                return "文件夹移动-源文件夹存在性校验通过关系linkOid ==>【{}】,文件夹oid ==>【{}】";
            }, () -> {
                return new Object[]{sourceFolder.getLinkOid(), sourceFolder.getOid()};
            });
            boolean targetFolderExist = subfolderLinkDOS.stream().anyMatch((subfolderLinkDO) -> {
                return subfolderLinkDO.getOid().equals(targetFolder.getLinkOid()) && subfolderLinkDO.getBoid().equals(new BigInteger(targetFolder.getOid()));
            });
            if (!targetFolderExist) {
                throw new TyException(Collections.singletonList(new TyException(ResponseCodeEnum.BIZ_OBJECT_NOT_FOUND, new String[]{targetFolder.getLinkOid().toString()})));
            } else {
                TyplmLoggerUtil.debug(log, () -> {
                    return "文件夹移动-目标文件夹存在性校验通过关系linkOid ==>【{}】,文件夹oid ==>【{}】";
                }, () -> {
                    return new Object[]{targetFolder.getLinkOid(), targetFolder.getOid()};
                });
                Set<BigInteger> parentOid = (Set)subfolderLinkDOS.stream().map(SubfolderLinkDO::getAoid).collect(Collectors.toSet());
                if (parentOid.size() != 1) {
                    throw FolderErrorCodeEnum.FOLDER_HAS_NOT_SAME_PARENT.getException(new Object[]{sourceFolder.getName() + "," + targetFolder.getName()});
                } else {
                    TyplmLoggerUtil.debug(log, () -> {
                        return "文件夹移动-同级目录校验通过。";
                    });
                    return subfolderLinkDOS;
                }
            }
        }
    }

    private void fillParamToMapPathVO(List<BigInteger> subFolderOidList, Map<BigInteger, SubFolderPathVO> map) {
        if (subFolderOidList.contains(BigInteger.ZERO)) {
            SubFolderPathVO zeroSubFolderPathVO = new SubFolderPathVO();
            zeroSubFolderPathVO.setFolderPath("/");
            zeroSubFolderPathVO.setSubFolderId("0");
            zeroSubFolderPathVO.setPathId("");
            map.put(BigInteger.ZERO, zeroSubFolderPathVO);
        }

        Set<BigInteger> oidList = map.keySet();
        subFolderOidList.stream().filter((item) -> {
            return !BigInteger.ZERO.equals(item) && !oidList.contains(item);
        }).forEach((item) -> {
            SubFolderPathVO subFolderPathVO = new SubFolderPathVO();
            subFolderPathVO.setSubFolderId(String.valueOf(item));
            subFolderPathVO.setFolderPath("");
            subFolderPathVO.setPathId("");
            map.put(item, subFolderPathVO);
        });
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public SubfolderDO updateSubfolder(SubfolderWebVO subfolderWebVO) {
        return this.updateSubfolder(subfolderWebVO, CommonUtil.getUser());
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    public void batchInsertSubFolderLink(Collection<SubfolderLinkDO> subfolderLinkDOList) {
        this.typlmSubfolderLinkMapper.batchInsertSubFolderLink(subfolderLinkDOList);
    }

    public void checkObjPermission(BigInteger oid, String otype, String access) {
        CTyEntityBaseDO entityBaseDO = CommonUtil.getEntity(new IdentifierEntity(oid, otype));
        this.typlmPermissionsUtil.checkObjectPermissionList(CommonUtil.getUser(), Collections.singletonList(entityBaseDO), access);
    }

    public List<RpmActiveFolderDTO> createFolderByRpmActive(List<RpmActiveFolderExtDTO> activeFolderList) {
        if (CollUtil.isEmpty(activeFolderList)) {
            return new ArrayList();
        } else {
            Map<BigInteger, RpmActiveFolderExtDTO> rpmActiveFolderExtDTOMap = (Map)activeFolderList.stream().collect(Collectors.toMap(RpmActiveFolderDTO::getActiveOid, (t) -> {
                return t;
            }, (k1, k2) -> {
                return k1;
            }));
            List<RpmActiveFolderExtDTO> sortedList = this.sortActiveFolderList(activeFolderList, BigInteger.valueOf(-1L));
            Map<String, List<RpmActiveFolderExtDTO>> subFolderMap = new HashMap();
            this.createFolder(rpmActiveFolderExtDTOMap, sortedList, subFolderMap);
            if (CollUtil.isNotEmpty(subFolderMap)) {
                this.resetRpmActiveFolderIndex(subFolderMap);
            }

            return ConvertUtils.sourceToTarget(activeFolderList, RpmActiveFolderDTO.class);
        }
    }

    public SubfolderLinkDO newSubfolderLink(IdentifierEntity parentIdentifier, IdentifierEntity memberIdentifier, UserDO userDO) {
        TyplmEntityBaseUtil.checkParamNotNull(parentIdentifier, "parentIdentifier");
        TyplmEntityBaseUtil.checkParamNotNull(memberIdentifier, "memberIdentifier");
        SubfolderLinkDO subfolderLinkDO = new SubfolderLinkDO();
        subfolderLinkDO.setOid(this.snowflakeIdComponent.getInstance().nextId());
        subfolderLinkDO.setOtype("ty.inteplm.folder.CTySubFolderLink");
        subfolderLinkDO.setAoid(parentIdentifier.getOid());
        subfolderLinkDO.setOtype(parentIdentifier.getOtype());
        subfolderLinkDO.setBoid(memberIdentifier.getOid());
        subfolderLinkDO.setBotype(memberIdentifier.getOtype());
        subfolderLinkDO.setNodeindex(0L);
        TyplmEntityBaseUtil.fillCommonFieldForCreate(subfolderLinkDO);
        subfolderLinkDO.setCreatoroid(userDO.getOid());
        subfolderLinkDO.setCreatorotype(userDO.getOtype());
        return subfolderLinkDO;
    }

    public void batchDeleteSubfolderLinkByBoid(List<BigInteger> subfolderOidList) {
        if (!CollectionUtils.isEmpty(subfolderOidList)) {
            BatchQueryHelper.deleteExampleColumnIn(subfolderOidList, SubfolderLinkDO.class, this.typlmSubfolderLinkMapper, "boid");
        }
    }

    private void createFolder(Map<BigInteger, RpmActiveFolderExtDTO> rpmActiveFolderExtDTOMap, List<RpmActiveFolderExtDTO> sortedList, Map<String, List<RpmActiveFolderExtDTO>> subFolderMap) {
        TyplmLoggerUtil.debug(log, () -> {
            return "createFolder的参数， sortedList ==【{}】";
        }, () -> {
            return new Object[]{sortedList};
        });
        if (!CollUtil.isEmpty(sortedList)) {
            Iterator var4 = sortedList.iterator();

            while(true) {
                BigInteger subfolderOid;
                String subfolderOtype;
                List children;
                do {
                    if (!var4.hasNext()) {
                        return;
                    }

                    RpmActiveFolderExtDTO rpmActiveFolderExtDTO = (RpmActiveFolderExtDTO)var4.next();
                    BigInteger parentNodeOid = rpmActiveFolderExtDTO.getParentNodeOid();
                    String parentNodeOType = rpmActiveFolderExtDTO.getParentNodeOType();
                    RpmActiveFolderExtDTO sourceActiveFolderExtDTO = (RpmActiveFolderExtDTO)rpmActiveFolderExtDTOMap.get(rpmActiveFolderExtDTO.getActiveOid());
                    List<SubfolderWebVO> subfolderWebVOS = this.querySubFolderListByParent(parentNodeOid, parentNodeOType);
                    if (CollUtil.isEmpty((Collection)subfolderWebVOS)) {
                        subfolderWebVOS = new ArrayList();
                    }

                    Map<String, SubfolderWebVO> subfolderWebVOMap = (Map)((List)subfolderWebVOS).stream().collect(Collectors.toMap(SubfolderWebVO::getName, (t) -> {
                        return t;
                    }, (k1, k2) -> {
                        return k1;
                    }));
                    SubfolderWebVO subfolderWebVO = (SubfolderWebVO)subfolderWebVOMap.get(rpmActiveFolderExtDTO.getName());
                    subfolderOid = null;
                    subfolderOtype = null;
                    if (ObjectUtils.isNotEmpty(subfolderWebVO)) {
                        subfolderOid = new BigInteger(subfolderWebVO.getOid());
                        subfolderOtype = subfolderWebVO.getOtype();
                    } else {
                        SubfolderVO subfolderVO = this.createSubfolderVO(rpmActiveFolderExtDTO);
                        SubfolderDO subfolder = this.createSubfolder(subfolderVO, CommonUtil.getUser());
                        subfolderOid = subfolder.getOid();
                        subfolderOtype = subfolder.getOtype();
                    }

                    rpmActiveFolderExtDTO.setSubfolderOid(subfolderOid);
                    rpmActiveFolderExtDTO.setSubfolderOType(subfolderOtype);
                    sourceActiveFolderExtDTO.setSubfolderOid(subfolderOid);
                    sourceActiveFolderExtDTO.setSubfolderOType(subfolderOtype);
                    List<RpmActiveFolderExtDTO> subfolderDTOS = (List)subFolderMap.get(parentNodeOid + ":" + parentNodeOType);
                    if (CollUtil.isEmpty((Collection)subfolderDTOS)) {
                        subfolderDTOS = new ArrayList();
                    }

                    ((List)subfolderDTOS).add(rpmActiveFolderExtDTO);
                    subFolderMap.put(parentNodeOid + ":" + parentNodeOType, subfolderDTOS);
                    children = rpmActiveFolderExtDTO.getChildren();
                } while(CollUtil.isEmpty(children));

                Iterator var16 = children.iterator();

                while(var16.hasNext()) {
                    RpmActiveFolderExtDTO rpmActiveFolderExtDTO1 = (RpmActiveFolderExtDTO)var16.next();
                    rpmActiveFolderExtDTO1.setParentNodeOid(subfolderOid);
                    rpmActiveFolderExtDTO1.setParentNodeOType(subfolderOtype);
                    RpmActiveFolderExtDTO sourceActiveFolderExtDTO1 = (RpmActiveFolderExtDTO)rpmActiveFolderExtDTOMap.get(rpmActiveFolderExtDTO1.getActiveOid());
                    sourceActiveFolderExtDTO1.setParentNodeOid(subfolderOid);
                    sourceActiveFolderExtDTO1.setParentNodeOType(subfolderOtype);
                }

                this.createFolder(rpmActiveFolderExtDTOMap, children, subFolderMap);
            }
        }
    }

    private void resetRpmActiveFolderIndex(Map<String, List<RpmActiveFolderExtDTO>> subFolderMap) {
        Iterator var2 = subFolderMap.entrySet().iterator();

        while(true) {
            Map.Entry entry;
            List subfolderWebVOS;
            do {
                if (!var2.hasNext()) {
                    return;
                }

                entry = (Map.Entry)var2.next();
                Map.Entry finalEntry = entry;
                TyplmLoggerUtil.debug(log, () -> {
                    return "resetRpmActiveFolderIndex的参数， entry ==【{}】";
                }, () -> {
                    return new Object[]{finalEntry};
                });
                String key = (String)entry.getKey();
                String[] split = key.split(":");
                BigInteger parentOid = new BigInteger(split[0]);
                String parentOtype = split[1];
                subfolderWebVOS = this.querySubFolderListByParent(parentOid, parentOtype);
                TyplmLoggerUtil.debug(log, () -> {
                    return "查询子文件夹入参， parentOid ==【{}】， parentOtype ==【{}】";
                }, () -> {
                    return new Object[]{parentOid, parentOtype};
                });
                List finalSubfolderWebVOS = subfolderWebVOS;
                TyplmLoggerUtil.debug(log, () -> {
                    return "查询子文件夹返回， subfolderWebVOS ==【{}】";
                }, () -> {
                    return new Object[]{finalSubfolderWebVOS};
                });
            } while(CollUtil.isEmpty(subfolderWebVOS));

            Map<String, SubfolderWebVO> subfolderWebVOMap = (Map)subfolderWebVOS.stream().collect(Collectors.toMap(SubfolderWebVO::getOid, (t) -> {
                return t;
            }, (k1, k2) -> {
                return k1;
            }));
            LinkedList<SubfolderWebVO> linkedList = (LinkedList)subfolderWebVOS.stream().collect(Collectors.toCollection(LinkedList::new));
            List<RpmActiveFolderExtDTO> valueList = (List)entry.getValue();
            Map<BigInteger, List<RpmActiveFolderExtDTO>> listMap = (Map)valueList.stream().collect(Collectors.groupingBy((x) -> {
                return (BigInteger)Optional.ofNullable(x.getPreNodeOid()).orElse(BigInteger.ZERO);
            }));
            Iterator var13 = listMap.entrySet().iterator();

            label76:
            while(var13.hasNext()) {
                Map.Entry<BigInteger, List<RpmActiveFolderExtDTO>> preEntry = (Map.Entry)var13.next();
                TyplmLoggerUtil.debug(log, () -> {
                    return "resetRpmActiveFolderIndex的参数， preEntry ==【{}】";
                }, () -> {
                    return new Object[]{preEntry};
                });
                BigInteger preNodeOid = (BigInteger)preEntry.getKey();
                List<RpmActiveFolderExtDTO> preValue = (List)preEntry.getValue();
                Map<String, List<RpmActiveFolderExtDTO>> positionMap = (Map)preValue.stream().collect(Collectors.groupingBy(RpmActiveFolderDTO::getPosition));
                Iterator var18 = positionMap.entrySet().iterator();

                while(true) {
                    while(true) {
                        if (!var18.hasNext()) {
                            continue label76;
                        }

                        Map.Entry<String, List<RpmActiveFolderExtDTO>> positionEntry = (Map.Entry)var18.next();
                        String position = (String)positionEntry.getKey();
                        List<RpmActiveFolderExtDTO> positionValue = (List)positionEntry.getValue();
                        positionValue = (List)positionValue.stream().sorted(Comparator.comparingInt(RpmActiveFolderDTO::getNodeIndex)).collect(Collectors.toList());
                        int i;
                        RpmActiveFolderExtDTO rpmActiveFolderExtDTO;
                        SubfolderWebVO subfolderWebVO;
                        SubfolderWebVO preSubfolderWebVO;
                        int preIndex;
                        if ("T".equals(position)) {
                            for(i = positionValue.size() - 1; i >= 0; --i) {
                                rpmActiveFolderExtDTO = (RpmActiveFolderExtDTO)positionValue.get(i);
                                subfolderWebVO = (SubfolderWebVO)subfolderWebVOMap.get(rpmActiveFolderExtDTO.getSubfolderOid().toString());
                                linkedList.remove(subfolderWebVO);
                                if (!ObjectUtils.isEmpty(preNodeOid) && !BigInteger.ZERO.equals(preNodeOid)) {
                                    preSubfolderWebVO = (SubfolderWebVO)subfolderWebVOMap.get(preNodeOid.toString());
                                    preIndex = linkedList.indexOf(preSubfolderWebVO);
                                    if (preIndex - 1 > 0) {
                                        linkedList.addFirst(subfolderWebVO);
                                    } else {
                                        linkedList.add(preIndex - positionValue.size() + i + 1, subfolderWebVO);
                                    }
                                } else {
                                    linkedList.addFirst(subfolderWebVO);
                                }
                            }
                        } else {
                            for(i = 0; i < positionValue.size(); ++i) {
                                rpmActiveFolderExtDTO = (RpmActiveFolderExtDTO)positionValue.get(i);
                                subfolderWebVO = (SubfolderWebVO)subfolderWebVOMap.get(rpmActiveFolderExtDTO.getSubfolderOid().toString());
                                linkedList.remove(subfolderWebVO);
                                if (!ObjectUtils.isEmpty(preNodeOid) && !BigInteger.ZERO.equals(preNodeOid)) {
                                    preSubfolderWebVO = (SubfolderWebVO)subfolderWebVOMap.get(preNodeOid.toString());
                                    preIndex = linkedList.indexOf(preSubfolderWebVO);
                                    if (preIndex + 1 >= linkedList.size()) {
                                        linkedList.addLast(subfolderWebVO);
                                    } else {
                                        linkedList.add(preIndex + i + 1, subfolderWebVO);
                                    }
                                } else {
                                    linkedList.addLast(subfolderWebVO);
                                }
                            }
                        }
                    }
                }
            }

            List<SubfolderWebVO> newList = (List)linkedList.stream().collect(Collectors.toList());
            this.restNodeIndex(newList);
        }
    }

    private SubfolderVO createSubfolderVO(RpmActiveFolderExtDTO rpmActiveFolderExtDTO) {
        SubfolderVO subfolderVO = new SubfolderVO();
        subfolderVO.setName(rpmActiveFolderExtDTO.getName());
        subfolderVO.setParentOid(rpmActiveFolderExtDTO.getParentNodeOid().toString());
        subfolderVO.setParentOtype(rpmActiveFolderExtDTO.getParentNodeOType());
        subfolderVO.setIsInheritedParent("1");
        return subfolderVO;
    }

    private List<RpmActiveFolderExtDTO> sortActiveFolderList(List<RpmActiveFolderExtDTO> activeFolderList, BigInteger parentActiveOid) {
        List<RpmActiveFolderExtDTO> parentList = (List)activeFolderList.stream().filter((p) -> {
            return p.getParentActiveOid().equals(parentActiveOid) || ObjectUtils.isNotEmpty(p.getParentNodeOid()) && ObjectUtils.isNotEmpty(p.getParentActiveOid());
        }).sorted(Comparator.comparingInt(RpmActiveFolderDTO::getNodeIndex)).collect(Collectors.toList());
        TyplmLoggerUtil.debug(log, () -> {
            return "sortActiveFolderList找到根节点， parentList ==【{}】";
        }, () -> {
            return new Object[]{parentList};
        });
        if (CollUtil.isEmpty(parentList)) {
            return new ArrayList();
        } else {
            Map<BigInteger, RpmActiveFolderExtDTO> collect = (Map)parentList.stream().collect(Collectors.toMap(RpmActiveFolderDTO::getActiveOid, (t) -> {
                return t;
            }, (k1, k2) -> {
                return k1;
            }));
            List<RpmActiveFolderExtDTO> otherList = (List)activeFolderList.stream().filter((p) -> {
                return !collect.containsKey(p.getActiveOid());
            }).collect(Collectors.toList());
            Iterator var6 = parentList.iterator();

            while(var6.hasNext()) {
                RpmActiveFolderExtDTO rpmActiveFolderExtDTO = (RpmActiveFolderExtDTO)var6.next();
                BigInteger activeOid = rpmActiveFolderExtDTO.getActiveOid();
                List<RpmActiveFolderExtDTO> children = this.sortActiveFolderList(otherList, activeOid);
                rpmActiveFolderExtDTO.setChildren(children);
            }

            return parentList;
        }
    }

    static {
        List<String> tempContainerType = new ArrayList();
        tempContainerType.add("ty.inteplm.product.CTyPDMLinkProduct");
        tempContainerType.add("ty.inteplm.library.CTyLibrary");
        tempContainerType.add("ty.inteplm.project.CTyProject");
        tempContainerType.add("ty.inteplm.folder.CTySubFolder");
        CONTAINER_TYPE = Collections.unmodifiableList(tempContainerType);
    }
}
